react-native-upi-payments
Version:
42 lines (41 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.initWithUri = exports.initWithParams = exports.fetchUpiApps = void 0;
exports.isAppInstalled = isAppInstalled;
exports.upiAppSelectListener = void 0;
var _reactNative = require("react-native");
var _UpiAppSelectListener = require("./UpiAppSelectListener");
const LINKING_ERROR = `The package 'react-native-upi-payments' doesn't seem to be linked. Make sure: \n\n` + _reactNative.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 = _reactNative.NativeModules.UpiPayment ? _reactNative.NativeModules.UpiPayment : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
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 ?? {});
};
exports.initWithParams = initWithParams;
const fetchUpiApps = options => {
return UpiPayment.fetchUpiApps(options ?? {});
};
exports.fetchUpiApps = fetchUpiApps;
const initWithUri = (uri, options) => {
if (!uri) Promise.reject('Invaid uri');
return UpiPayment.payWithUri(uri, options ?? {});
};
exports.initWithUri = initWithUri;
function isAppInstalled(packageName) {
return UpiPayment.isAppInstalled(packageName);
}
const upiAppSelectListener = exports.upiAppSelectListener = new _UpiAppSelectListener.UpiAppSelectListener();
//# sourceMappingURL=index.js.map