Skip to content

Commit 154da40

Browse files
malithsenMayisha
andauthored
Fix Google Pay 3DS modal (#4528)
* Extract redirect URL from payment_details * Add a unit test * Add changelog entry * Update changelog entry * Update changelog entry Co-authored-by: Mayisha <[email protected]> * Update changelog entry Co-authored-by: Mayisha <[email protected]> --------- Co-authored-by: Mayisha <[email protected]>
1 parent 77d37ff commit 154da40

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Update - Improve Stripe API connector logging to include request/response context
1919
* Fix - Fix fatal when processing setup intents for free subscriptions via webhooks
2020
* Fix - Prevent Stripe API calls after several consecutive 401 (Unauthorized) responses
21+
* Fix - 3DS authentication modal not shown when using Google Pay
2122
* Update - Improve Stripe API connector logging to include request/response context
2223

2324
= 9.7.0 - 2025-07-21 =

client/express-checkout/__tests__/event-handler.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,5 +616,55 @@ describe( 'Express checkout event handlers', () => {
616616
);
617617
expect( completePayment ).not.toHaveBeenCalled();
618618
} );
619+
620+
test( 'should extract redirect URL from payment_details when redirect_url is empty for 3DS authentication', async () => {
621+
const threeDSRedirectUrl =
622+
'#confirm-pi-pi_1234567890abcdef_secret_test1234567890abcdef:fake_nonce';
623+
624+
elements.submit.mockResolvedValue( {} );
625+
stripe.createPaymentMethod.mockResolvedValue( {
626+
paymentMethod: { id: 'pm_123' },
627+
} );
628+
api.expressCheckoutECECreateOrder.mockResolvedValue( {
629+
payment_result: {
630+
payment_status: 'success',
631+
payment_details: [
632+
{
633+
key: 'result',
634+
value: 'success',
635+
},
636+
{
637+
key: 'redirect',
638+
value: threeDSRedirectUrl,
639+
},
640+
{
641+
key: 'payment_method',
642+
value: 'pm_test1234567890abcdef',
643+
},
644+
],
645+
redirect_url: '',
646+
},
647+
} );
648+
649+
api.confirmIntent.mockReturnValue( true );
650+
651+
await onConfirmHandler( {
652+
api,
653+
stripe,
654+
elements,
655+
completePayment,
656+
abortPayment,
657+
event,
658+
} );
659+
660+
expect( api.expressCheckoutECECreateOrder ).toHaveBeenCalled();
661+
expect( api.confirmIntent ).toHaveBeenCalledWith(
662+
threeDSRedirectUrl
663+
);
664+
expect( completePayment ).toHaveBeenCalledWith(
665+
threeDSRedirectUrl
666+
);
667+
expect( abortPayment ).not.toHaveBeenCalled();
668+
} );
619669
} );
620670
} );

client/express-checkout/payment-flow.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,20 @@ const processOrder = async ( {
184184
);
185185
}
186186

187+
// Extract redirect URL from payment_details if redirect_url is empty
188+
let redirectUrl = orderResponse?.payment_result?.redirect_url;
189+
if ( ! redirectUrl ) {
190+
const redirectDetail = orderResponse?.payment_result?.payment_details?.find(
191+
( detail ) => detail.key === 'redirect'
192+
);
193+
redirectUrl = redirectDetail?.value || '';
194+
}
195+
187196
return {
188197
result: orderResponse?.payment_result?.payment_status,
189198
errorMessage: orderResponse?.payment_result?.payment_details?.find(
190199
( detail ) => detail.key === 'errorMessage'
191200
)?.value,
192-
redirect: orderResponse?.payment_result?.redirect_url,
201+
redirect: redirectUrl,
193202
};
194203
};

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
127127
* Fix - Fix required field error message and PHP warning for custom checkout fields that don't have a label
128128
* Fix - Fix fatal when processing setup intents for free subscriptions via webhooks
129129
* Fix - Prevent Stripe API calls after several consecutive 401 (Unauthorized) responses
130+
* Fix - 3DS authentication modal not shown when using Google Pay
130131
* Update - Improve Stripe API connector logging to include request/response context
131132

132133
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 commit comments

Comments
 (0)