-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.js
40 lines (36 loc) · 1.14 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,
expiration_date: parameters.expirationDate,
cardholder_name: parameters.cardholderName,
billing_address: {
postal_code: parameters.postalCode,
street_address: parameters.streetAddress,
extended_address: parameters.extendedAddress,
locality: parameters.locality,
region: parameters.region,
country_name: parameters.countryName,
country_code_alpha2: parameters.countryCodeAlpha2,
country_code_alpha3: parameters.countryCodeAlpha3,
country_code_numeric: parameters.countryCodeNumeric,
first_name: parameters.firstName,
last_name: parameters.lastName,
company: parameters.company
},
};
}