-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.android.js
51 lines (47 loc) · 1.18 KB
/
index.android.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
46
47
48
49
50
51
'use strict';
import {
NativeModules,
NativeEventEmitter,
} from 'react-native';
const Braintree = NativeModules.Braintree;
module.exports = {
setup(token) {
return new Promise(function(resolve, reject) {
Braintree.setup(token, test => resolve(test), err => reject(err));
});
},
showPayPalViewController(amount, shippingRequired, currencyCode) {
return new Promise(function(resolve, reject) {
const paypalEmitter = new NativeEventEmitter();
paypalEmitter.addListener("PaypalStatus", (params) => callback(params));
const callback = (params) => {
paypalEmitter.removeAllListeners("PaypalStatus");
if (params.error) {
reject(params.error);
} else {
const {
nonce,
email,
firstName,
lastName,
phone,
shippingAddress
} = params;
resolve({
nonce,
email,
firstName,
lastName,
phone,
shipping: shippingAddress
});
}
}
Braintree.paypalRequest(
amount,
shippingRequired,
currencyCode
);
});
},
};