-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
45 lines (39 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { NativeModules } from 'react-native';
const JS_CALLBACK_IS_ERROR = 'error';
const JS_CALLBACK_IS_DISMISS = 'dismiss';
const PayHere = function(){
var startPayment = function(
paymentObject,
onCompleted,
onError,
onDismissed
) {
NativeModules.PayhereOfficial.startPayment(
paymentObject,
({success, jsdata, jscallback}) => {
try{
if (success){
onCompleted(jsdata);
}
else{
if (jscallback == JS_CALLBACK_IS_ERROR){
onError(jsdata);
}
else if (jscallback == JS_CALLBACK_IS_DISMISS){
onDismissed();
}
else{
onError('Unknown callback');
}
}
}
catch(error){
onError(error);
}
});
}
return {
startPayment
}
}();
export default PayHere;