forked from kraffslol/react-native-braintree-xplat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
40 lines (36 loc) · 1.13 KB
/
utils.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
// @flow
import { Platform } from 'react-native';
import type {
CardParameters,
AndroidCardParameters,
IOSCardParameters,
} from './types';
export function mapParameters(
parameters: CardParameters
): AndroidCardParameters | IOSCardParameters {
if (Platform.OS === 'android') {
return parameters;
}
// iOS field mapping
// https://github.com/braintree/braintree_ios/blob/master/BraintreeCard/BTCard.m#L14
return {
number: parameters.number,
cvv: parameters.cvv,
expirationDate: parameters.expirationDate,
cardholderName: parameters.cardholderName,
billingAddress: {
postalCode: parameters.postalCode,
streetAddress: parameters.streetAddress,
extendedAddress: parameters.extendedAddress,
locality: parameters.locality,
region: parameters.region,
countryName: parameters.countryName,
countryCodeAlpha2: parameters.countryCodeAlpha2,
countryCodeAlpha3: parameters.countryCodeAlpha3,
countryCodeNumeric: parameters.countryCodeNumeric,
firstName: parameters.firstName,
lastName: parameters.lastName,
company: parameters.company,
},
};
}