Skip to content

Commit

Permalink
feat(payments): PAYPAL-1713 modified method for ACH
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-nick committed Mar 27, 2023
1 parent be5fec1 commit ac86b05
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/payment/payment-method-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const BRAINTREE_PAYPAL = 'braintreepaypal';
export const BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit';
export const BRAINTREE_VISACHECKOUT = 'braintreevisacheckout';
export const BRAINTREE_GOOGLEPAY = 'googlepaybraintree';
export const BRAINTREE_ACH = 'braintreeach';

export const PAYPAL_COMMERCE = 'paypalcommerce';
export const PAYPAL_COMMERCE_ALTERNATIVE_METHODS = 'paypalcommercealternativemethods';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PAYPAL_COMMERCE_ALTERNATIVE_METHODS,
PAYPAL_COMMERCE_INLINE,
PAYPAL_COMMERCE_VENMO,
BRAINTREE_ACH,
} from '../payment-method-ids';

/**
Expand All @@ -23,6 +24,7 @@ function isBraintreePaymentMethod(id) {
case BRAINTREE_PAYPAL_CREDIT:
case BRAINTREE_VISACHECKOUT:
case BRAINTREE_GOOGLEPAY:
case BRAINTREE_ACH:
return true;
default:
return false;
Expand Down
1 change: 1 addition & 0 deletions src/payment/payment-method-types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const CREDIT_CARD = 'credit-card';
export const PAYPAL_ACH = 'paypal-ach';
export const MULTI_OPTION = 'multi-option';
export const PPSDK_CREDIT_CARD = 'card';
12 changes: 11 additions & 1 deletion src/payment/v1/payment-mappers/payment-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import objectAssign from 'object-assign';
import { omitNil, toNumber } from '../../../common/utils';

import PaymentMethodIdMapper from '../../payment-method-mappers/payment-method-id-mapper';
import { PAYPAL_ACH } from '../../payment-method-types';

export default class PaymentMapper {
/**
Expand Down Expand Up @@ -51,7 +52,7 @@ export default class PaymentMapper {
const { method } = paymentMethod;

if (method) {
objectAssign(payload, { method });
objectAssign(payload, { method: this.mapToMethod(method) });
}

const nonce = payment.nonce || paymentMethod.nonce;
Expand Down Expand Up @@ -87,6 +88,15 @@ export default class PaymentMapper {
return omitNil(payload);
}

/**
* @private
* @param {method} method
* @return {string}
*/
mapToMethod(method) {
return method === PAYPAL_ACH ? 'ach' : method;
}

/**
* @private
* @param {PaymentRequestData} data
Expand Down

0 comments on commit ac86b05

Please sign in to comment.