react-native-upi-payments
Version:
31 lines • 1.34 kB
JavaScript
import { NativeModules, Platform } from 'react-native';
import { UpiAppSelectListener } from './UpiAppSelectListener';
const LINKING_ERROR = `The package 'react-native-upi-payments' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
const UpiPayment = NativeModules.UpiPayment ? NativeModules.UpiPayment : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
export const initWithParams = (params, options) => {
if (!params.currency) {
params.currency = 'INR';
}
if (!params.receiverUpi) return Promise.reject('Receiver upi id not entered');
if (typeof params.amount != 'number' || Number(params.amount) <= 0) return Promise.reject('Amount is not valid');
return UpiPayment.initWithParams(params, options ?? {});
};
export const fetchUpiApps = options => {
return UpiPayment.fetchUpiApps(options ?? {});
};
export const initWithUri = (uri, options) => {
if (!uri) Promise.reject('Invaid uri');
return UpiPayment.payWithUri(uri, options ?? {});
};
export function isAppInstalled(packageName) {
return UpiPayment.isAppInstalled(packageName);
}
export const upiAppSelectListener = new UpiAppSelectListener();
//# sourceMappingURL=index.js.map