From 5f6f79aff40f07b8f0562640aafb36b08a20993a Mon Sep 17 00:00:00 2001 From: Greg Jopa <534034+gregjopa@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:27:52 -0500 Subject: [PATCH] Improve the check for instrument declined use case --- advanced-integration/public/app.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/advanced-integration/public/app.js b/advanced-integration/public/app.js index 02f484f6..43fb25d9 100644 --- a/advanced-integration/public/app.js +++ b/advanced-integration/public/app.js @@ -55,13 +55,8 @@ async function onApproveCallback(data, actions) { orderData?.purchase_units?.[0]?.payments?.authorizations?.[0]; const errorDetail = orderData?.details?.[0]; - const isHostedFieldsComponent = typeof data.card === "object"; - // this actions.restart() behavior only applies to the Buttons component - if ( - errorDetail?.issue === "INSTRUMENT_DECLINED" && - isHostedFieldsComponent === false - ) { + if (errorDetail?.issue === "INSTRUMENT_DECLINED" && !data.card && actions) { // (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart() // recoverable state, per https://developer.paypal.com/docs/checkout/standard/customize/handle-funding-failures/ return actions.restart();