UNPKG

react-native-razorpay

Version:
76 lines (68 loc) 1.77 kB
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, TouchableHighlight, NativeModules, NativeEventEmitter } from 'react-native'; import RazorpayCheckout from 'react-native-razorpay'; class example extends Component { render() { return ( <View style={styles.container}> <TouchableHighlight onPress={() => { var options = { description: 'Credits towards consultation', image: 'https://i.imgur.com/3g7nmJC.png', currency: 'INR', key: 'rzp_test_1DP5mmOlF5G5ag', amount: '5000', external: { wallets: ['paytm'] }, name: 'foo', prefill: { email: 'akshay@razorpay.com', contact: '8955806560', name: 'Akshay Bhalotia' }, theme: {color: '#F37254'} } RazorpayCheckout.open(options).then((data) => { // handle success alert(`Success: ${data.razorpay_payment_id}`); }).catch((error) => { // handle failure alert(`Error: ${error.code} | ${error.description}`); }); RazorpayCheckout.onExternalWalletSelection(data => { alert(`External Wallet Selected: ${data.external_wallet} `); }); }}> <Text style = {styles.text}>PAY</Text> </TouchableHighlight> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, text: { fontSize: 20, fontWeight: 'bold', } }); AppRegistry.registerComponent('example', () => example);