crzgoku / razorpay-capacitor

Capacitor wrapper around Razorpay's Android and iOS SDKs

Home Page:https://www.npmjs.com/package/com.razorpay.capacitor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


razorpay-capacitor

razorpay-capacitor

Capacitor wrapper around Razorpay's Android and iOS SDKs

Installation

  • npm i -S https://github.com/razorpay/razorpay-capacitor.git

Adding Plugin For Android Integration

Add the Checkout class to the ArrayList in the MainActivity class in {{projectDir}}/android/src/main/MainActivity.java

import com.ionicframework.capacitor.Checkout;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(Checkout.class);
    }});
  }
}

Usage (iOS, Web, Android)

import  'capacitor-razorpay';
import { Plugins } from '@capacitor/core';
const { Checkout } = Plugins;

  async loadCheckout() {
    const options = { 
      key: 'rzp_test_1DP5mmOlF5G5ag',
      amount: '5000',
      description: 'Credits towards consultation', 
      image: 'https://i.imgur.com/3g7nmJC.png', 
      currency: 'INR', 
      name: 'foo', 
      prefill: { 
        email: 'void@razorpay.com', 
        contact: '9191919191', 
        name: 'Razorpay Software'
      },
      theme: {
        color: '#F37254'
      }
    }
    try {
    let data = (await Checkout.open(options));
    this.presentAlert(data.response);
    } catch (error) {
      this.presentAlert(error.message); //Doesn't appear at all
    }
  }

About

Capacitor wrapper around Razorpay's Android and iOS SDKs

https://www.npmjs.com/package/com.razorpay.capacitor


Languages

Language:TypeScript 35.6%Language:SCSS 20.1%Language:Swift 15.5%Language:Java 11.6%Language:JavaScript 9.2%Language:Ruby 3.8%Language:HTML 2.6%Language:Objective-C 1.7%