Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/UpiPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { NativeModules } from 'react-native';

const UpiModule = NativeModules.UpiPayment;

function isNull(data) {
if (data === '' || data === 'null' || data === null || data === undefined) {
return true;
} else {
false;
}
}

const RNUpiPayment = {
requiredFields: [
Expand Down Expand Up @@ -80,7 +87,7 @@ const RNUpiPayment = {
return object;
},

initializePayment(config, success, failure) {
initializePayment(config, success, failure, payApp) {
if (typeof success !== 'function') {
throw new Error('Success callback not a function');
}
Expand Down Expand Up @@ -112,9 +119,10 @@ const RNUpiPayment = {
return accumulator;
}, '');
const upiConfig = {}
upiConfig.upiString = `upi://pay?${queryString}`;
const app = isNull(payApp) ? "" : (payApp + "://");
upiConfig.upiString = app +`upi://pay?${queryString}`;
UpiModule.intializePayment(upiConfig, this.successCallback(success), this.failureCallback(failure));
}
}

module.exports = RNUpiPayment;
module.exports = RNUpiPayment;