Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fields (customer, paymentMethod) {
const response = {};
if (paymentMethod instanceof braintree.CreditCard) {
Object.assign(response, {
__t: 'CreditCard',
maskedNumber: paymentMethod.maskedNumber,
countryOfIssuance: paymentMethod.countryOfIssuance,
issuingBank: paymentMethod.issuingBank,
cardType: paymentMethod.cardType,
cardholderName: paymentMethod.cardholderName,
expirationMonth: paymentMethod.expirationMonth,
expirationYear: paymentMethod.expirationYear,
});
} else if (paymentMethod instanceof braintree.PayPalAccount) {
Object.assign(response, {
__t: 'PayPalAccount',
name: name.full(paymentMethod.payerInfo.firstName, paymentMethod.payerInfo.lastName),
payerId: paymentMethod.payerInfo.payerId,
email: paymentMethod.email,
});
} else if (paymentMethod instanceof braintree.ApplePayCard) {
Object.assign(response, {
__t: 'ApplePayCard',
cardType: paymentMethod.cardType,
paymentInstrumentName: paymentMethod.paymentInstrumentName,
expirationMonth: paymentMethod.expirationMonth,
expirationYear: paymentMethod.expirationYear,
});
} else if (paymentMethod instanceof braintree.AndroidPayCard) {
Object.assign(response, {