Capacitor wrapper around Razorpay's Android and iOS SDKs
npm i -S https://github.com/razorpay/razorpay-capacitor.git
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);
}});
}
}
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: '[email protected]',
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
}
}