diff --git a/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.spec.ts b/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.spec.ts index 3b6303ff66..4e36387085 100644 --- a/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.spec.ts +++ b/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.spec.ts @@ -126,6 +126,7 @@ describe('GooglePayBraintreeGateway', () => { number: '1111', type: 'VISA', bin: '401288', + isNetworkTokenized: false, }, }; @@ -172,6 +173,7 @@ describe('GooglePayBraintreeGateway', () => { type: 'type', number: '1234', bin: 'bin', + isNetworkTokenized: false, }; await googlePayBraintreeGateway.initialize(() => braintree); @@ -189,6 +191,26 @@ describe('GooglePayBraintreeGateway', () => { type: 'type', number: '1234', bin: 'bin', + isNetworkTokenized: false, + }; + + await googlePayBraintreeGateway.initialize(() => braintree); + + const nonce = await googlePayBraintreeGateway.getNonce('googlepaybraintree'); + + expect(braintreeSdk.getBraintreeThreeDS).not.toHaveBeenCalled(); + expect(nonce).toBe('token'); + }); + + it('get nonce when card is network tokenized', async () => { + const braintree = getBraintree(); + + braintree.initializationData!.isThreeDSecureEnabled = true; + braintree.initializationData!.card_information = { + type: 'type', + number: '1234', + bin: 'bin', + isNetworkTokenized: true, }; await googlePayBraintreeGateway.initialize(() => braintree); diff --git a/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.ts b/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.ts index 51be6091bf..ebebe8bd09 100644 --- a/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.ts +++ b/packages/google-pay-integration/src/gateways/google-pay-braintree-gateway.ts @@ -62,10 +62,10 @@ export default class GooglePayBraintreeGateway extends GooglePayGateway { const { isThreeDSecureEnabled, - card_information: { bin }, + card_information: { bin, isNetworkTokenized }, } = initializationData; - if (isThreeDSecureEnabled) { + if (isThreeDSecureEnabled && !isNetworkTokenized) { const threeDSecure = await this._braintreeSdk.getBraintreeThreeDS(); const { orderAmount } = this._service.getState().getOrderOrThrow(); @@ -106,6 +106,8 @@ export default class GooglePayBraintreeGateway extends GooglePayGateway { data.nonce = token.androidPayCards[0].nonce; data.card_information.bin = token.androidPayCards[0].details.bin; + data.card_information.isNetworkTokenized = + token.androidPayCards[0].details.isNetworkTokenized; return data; } diff --git a/packages/google-pay-integration/src/types.ts b/packages/google-pay-integration/src/types.ts index 4260b2b708..a641758b83 100644 --- a/packages/google-pay-integration/src/types.ts +++ b/packages/google-pay-integration/src/types.ts @@ -291,7 +291,7 @@ export interface GooglePayHostWindow extends Window { } interface GooglePayBaseInitializationData { - card_information?: { type: string; number: string; bin?: string }; + card_information?: { type: string; number: string; bin?: string; isNetworkTokenized?: boolean }; gateway: string; gatewayMerchantId?: string; googleMerchantId: string; @@ -363,7 +363,7 @@ export type GooglePayInitializationData = export interface GooglePaySetExternalCheckoutData { nonce: string; - card_information: { type: string; number: string; bin?: string }; + card_information: { type: string; number: string; bin?: string; isNetworkTokenized?: boolean }; cart_id?: string; } @@ -393,6 +393,7 @@ export interface GooglePayBraintreeTokenObject { nonce: string; details: { bin: string; + isNetworkTokenized?: boolean; }; }, ];