Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions client/blocks/upe/upe-deferred-intent-creation/payment-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const PaymentElements = ( {
mode: amount < 1 ? 'setup' : 'payment',
amount,
currency: getBlocksConfiguration()?.currency.toLowerCase(),
paymentMethodTypes: getPaymentMethodTypes( paymentMethodId ),
},
};

Expand All @@ -148,29 +149,19 @@ const PaymentElements = ( {
?.paymentMethodConfigurationParentId,
},
};
} else {
} else if (
shouldSetupOffSessionPayment(
props.showSaveOption,
paymentMethodsConfig[ paymentMethodId ].isReusable
)
) {
// If the cart contains a auto-renewing subscription or the payment method supports saving, we need to use off_session setup so Stripe can display appropriate terms and conditions.
options = {
...options,
...{
paymentMethodTypes:
getPaymentMethodTypes( paymentMethodId ),
setupFutureUsage: 'off_session',
},
};

// If the cart contains a auto-renewing subscription or the payment method supports saving, we need to use off_session setup so Stripe can display appropriate terms and conditions.
if (
shouldSetupOffSessionPayment(
props.showSaveOption,
paymentMethodsConfig[ paymentMethodId ].isReusable
)
) {
options = {
...options,
...{
setupFutureUsage: 'off_session',
},
};
}
}
} else {
options = {
Expand Down
12 changes: 9 additions & 3 deletions client/stripe-utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,20 @@ export const isAmazonPayEnabled = () => {
/**
* Get array of payment method types to use with intent.
*
* @todo Make paymentMethodType required when Split is implemented.
*
* @param {string} paymentMethodType Payment method type Stripe ID.
* @return {Array} Array of payment method types to use with intent.
*/
export const getPaymentMethodTypes = ( paymentMethodType = null ) => {
export const getPaymentMethodTypes = ( paymentMethodType ) => {
const paymentMethodsConfig = getStripeServerData()?.paymentMethodsConfig;

// If OC is enabled, we always want to keep only the allowed payment methods.
if ( getStripeServerData()?.isOCEnabled ) {
return (
paymentMethodsConfig?.[ PAYMENT_METHOD_CARD ]
.enabledPaymentMethods || [ PAYMENT_METHOD_CARD ]
);
}

if ( paymentMethodType === null ) {
if (
getStripeServerData()?.isCheckout ||
Expand Down
Loading