npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

com.razorpay.cordova

v1.4.15

Published

Cordova/Phonegap bindings for Razorpay's Mobile SDKs

Downloads

959

Readme

Cordova/Phonegap bindings for Razorpay's Mobile SDKs

NPM Version NPM Downloads Install Size

Official Cordova/Phonegap plugin for integrating Razorpay's checkout.

Supported platforms

  • Android
  • iOS
  • Browser

You can check out the sample apps for:-

Usage:

Install the plugin

Note: For Windows users, please run this on Git Bash instead of Command Prompt. You can download Git for Windows here.

cd your-project-folder
cordova platform add android      # optional
cordova platform add ios          # make sure your ios version is ios@5 or latest.
cordova platform add browser      # optional
cordova plugin add https://github.com/razorpay/razorpay-cordova.git --save

(or, phonegap plugin add https://github.com/razorpay/razorpay-cordova.git --save)

Note: Make sure that you set Always Embed Swift Standard Libraries of your main target to yes.

Note: Remember to enable bitcode on your iOS project. We support Xcode 11+ versions.

Integration code

Orders API Flow

With the advent of auto-capture using Order API, the integration needs to change a little (only if you are using this flow). The only change is that the callbacks have to be added as events. Here is a code sample:

var options = {
  description: 'Credits towards consultation',
  image: 'https://i.imgur.com/3g7nmJC.png',
  currency: 'INR',
  key: 'rzp_test_1DP5mmOlF5G5ag',
  order_id: 'order_7HtFNLS98dSj8x',
  amount: '5000',
  name: 'foo',
  theme: {
    color: '#F37254'
  }
}

var successCallback = function(success) {
  alert('payment_id: ' + success.razorpay_payment_id)
  var orderId = success.razorpay_order_id
  var signature = success.razorpay_signature
}

var cancelCallback = function(error) {
  alert(error.description + ' (Error '+error.code+')')
}

RazorpayCheckout.on('payment.success', successCallback)
RazorpayCheckout.on('payment.cancel', cancelCallback)
RazorpayCheckout.open(options)

Change the options accordingly. Supported options can be found here.

External Wallets

We also support displaying wallets like Citrus and Paytm, which are currently not a part of the standard Razorpay offering. After the user chooses which one of these they want, control is handed back to you with data like wallet name, contact and email of the user. This helps you take the next steps towards facilitating the payment and Razorpay's role in that payment cycle ends there.

To add a wallet, change the options JSON as follows:

var options = {
  currency: 'INR',
  key: 'rzp_test_1DP5mmOlF5G5ag',
  amount: '5000',
  external: {
    wallets: ['paytm']
  },
  ...
  ...
  ...
}

To get callback for this, add this before calling open:

RazorpayCheckout.on('payment.external_wallet', externalWalletCallback)

Legacy

This is legacy integration code and we will continue to support it till further notice. Your server needs to send capture request in this scenario, after the payment is completed.

var options = {
  description: 'Credits towards consultation',
  image: 'https://i.imgur.com/3g7nmJC.png',
  currency: 'INR',
  key: 'rzp_test_1DP5mmOlF5G5ag',
  amount: '5000',
  name: 'foo',
  theme: {
    color: '#F37254'
  }
}

var successCallback = function(payment_id) {
  alert('payment_id: ' + payment_id)
}

var cancelCallback = function(error) {
  alert(error.description + ' (Error '+error.code+')')
}

RazorpayCheckout.open(options, successCallback, cancelCallback)

Android Lifecycle Guide

It is recomended that you read this first before proceeding with this section

Since our plugin launches a new activity on Android, the cordova activity goes in the background and might get destroyed by the Android System. For this scenario, you need to add the following code to make sure the payment result is delivered after the cordova activity is recreated:

// You need to register an event listener for the `resume` event
document.addEventListener('resume', onResume, false);
var onResume = function(event) {
        // Re-register the payment success and cancel callbacks
        RazorpayCheckout.on('payment.success', successCallback)
        RazorpayCheckout.on('payment.cancel', cancelCallback)
        // Pass on the event to RazorpayCheckout
        RazorpayCheckout.onResume(event);
      };

Things to be taken care:

  • Add the integration code snippet after deviceready event.

  • On browser platform, change the Content Security Policy to whitelist the razorpay.com domain.

<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://*.razorpay.com data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
  • Due to the way ionic works, we can't support ionic serve at the moment. Try using ionic run browser instead of ionic serve. ionic serve doesn't support cordova browser plugins at the moment. See driftyco/ionic-cli#354.

FAQ

If you are still not able to integrate, then go to FAQ.

Note

We don't support capacitor because of the app support dependency, for more details go through this link.