Skip to content

Removing card requirement for OC #4573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9109f75
Removing card requirement for OC
wjrosa Aug 11, 2025
27848e1
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 11, 2025
6dd474b
Backend changes
wjrosa Aug 11, 2025
fc32555
Merge branch 'fix/removing-card-requirement-for-oc' of https://github…
wjrosa Aug 11, 2025
bfa1738
Backend changes
wjrosa Aug 11, 2025
074f9fb
Changelog and readme entries
wjrosa Aug 11, 2025
73d97f4
Fix tests
wjrosa Aug 11, 2025
a93ecb0
Fix tests
wjrosa Aug 11, 2025
172e0ed
unit test
wjrosa Aug 11, 2025
896e3d0
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 11, 2025
e29852a
Fix tests
wjrosa Aug 11, 2025
12c5bba
Fix shortcode checkout methods display
wjrosa Aug 12, 2025
52464b8
Removing unnecessary condition
wjrosa Aug 12, 2025
4c5faaa
Condition is actually necessary
wjrosa Aug 12, 2025
799c5d6
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 13, 2025
d87a919
Removing disabledButChecked prop and related code
wjrosa Aug 13, 2025
51c8994
Removing the required for OC pill and related files
wjrosa Aug 13, 2025
b3665a8
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 14, 2025
55c5fc3
Merge branch 'dev/removing-required-for-oc-pill' into fix/removing-ca…
wjrosa Aug 14, 2025
467aef1
Hide OC container when there are no methods available
wjrosa Aug 14, 2025
f86bdea
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 14, 2025
954eff8
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 14, 2025
79716e2
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 14, 2025
44973f1
Fix merge
wjrosa Aug 14, 2025
a1062e9
Fix tests
wjrosa Aug 14, 2025
aecd42a
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 14, 2025
fb4c602
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 18, 2025
4cdbfac
Fix express methods not available
wjrosa Aug 18, 2025
ca92945
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 18, 2025
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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Changelog ***

= 9.9.0 - xxxx-xx-xx =
* Fix - Removes the credit card payment method requirement for the Optimized Checkout feature
* Fix - Payment method test instructions not showing up for the Optimized Checkout payment element
* Add - Includes a new notice to highlight the Optimized Checkout feature above the payment methods list in the Stripe settings page
* Update - Increases the default font size for the Optimized Checkout payment element to match the rest of the checkout form
Expand Down
42 changes: 17 additions & 25 deletions client/blocks/upe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import {
PAYMENT_METHOD_AFFIRM,
PAYMENT_METHOD_AMAZON_PAY,
PAYMENT_METHOD_CARD,
PAYMENT_METHOD_GIROPAY,
PAYMENT_METHOD_KLARNA,
PAYMENT_METHOD_LINK,
Expand Down Expand Up @@ -40,32 +39,25 @@ const api = new WCStripeAPI(
const paymentMethodsConfig =
getBlocksConfiguration()?.paymentMethodsConfig ?? {};

// Register UPE Elements.
if ( getBlocksConfiguration()?.isOCEnabled ) {
registerPaymentMethod(
upeElement( PAYMENT_METHOD_CARD, api, paymentMethodsConfig.card )
);
} else {
const methodsToFilter = [
PAYMENT_METHOD_AMAZON_PAY,
PAYMENT_METHOD_LINK,
PAYMENT_METHOD_GIROPAY, // Skip giropay as it was deprecated by Jun, 30th 2024.
];

// Filter out some BNPLs when other official extensions are present.
if ( getBlocksConfiguration()?.hasAffirmGatewayPlugin ) {
methodsToFilter.push( PAYMENT_METHOD_AFFIRM );
}
if ( getBlocksConfiguration()?.hasKlarnaGatewayPlugin ) {
methodsToFilter.push( PAYMENT_METHOD_KLARNA );
}
const methodsToFilter = [
PAYMENT_METHOD_AMAZON_PAY,
PAYMENT_METHOD_LINK,
PAYMENT_METHOD_GIROPAY, // Skip giropay as it was deprecated by Jun, 30th 2024.
];

Object.entries( paymentMethodsConfig )
.filter( ( [ method ] ) => ! methodsToFilter.includes( method ) )
.forEach( ( [ method, config ] ) => {
registerPaymentMethod( upeElement( method, api, config ) );
} );
// Filter out some BNPLs when other official extensions are present.
if ( getBlocksConfiguration()?.hasAffirmGatewayPlugin ) {
methodsToFilter.push( PAYMENT_METHOD_AFFIRM );
}
if ( getBlocksConfiguration()?.hasKlarnaGatewayPlugin ) {
methodsToFilter.push( PAYMENT_METHOD_KLARNA );
}

Object.entries( paymentMethodsConfig )
.filter( ( [ method ] ) => ! methodsToFilter.includes( method ) )
.forEach( ( [ method, config ] ) => {
registerPaymentMethod( upeElement( method, api, config ) );
} );

if ( getBlocksConfiguration()?.isECEEnabled ) {
// Register Express Checkout Elements.
Expand Down
14 changes: 14 additions & 0 deletions client/blocks/upe/upe-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
PAYMENT_METHOD_AFTERPAY_CLEARPAY,
PAYMENT_METHOD_CLEARPAY,
PAYMENT_METHOD_BACS,
PAYMENT_METHOD_CARD,
EXPRESS_PAYMENT_METHODS,
} from 'wcstripe/stripe-utils/constants';
import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
import Icons from 'wcstripe/payment-method-icons';
Expand Down Expand Up @@ -78,6 +80,18 @@ export const upeElement = ( paymentMethod, api, upeConfig ) => {
return false;
}

const nonExpressPaymentMethods = upeConfig?.enabledPaymentMethods.filter(
( method ) => ! EXPRESS_PAYMENT_METHODS.includes( method )
);

if (
paymentMethod === PAYMENT_METHOD_CARD &&
getBlocksConfiguration()?.isOCEnabled &&
nonExpressPaymentMethods.length === 0
) {
return false;
}

return isAvailableInTheCountry && !! api.getStripe();
},
// see .wc-block-checkout__payment-method styles in blocks/style.scss
Expand Down

This file was deleted.

87 changes: 0 additions & 87 deletions client/components/payment-method-required-for-oc-pill/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const PaymentMethodCheckbox = ( {
label,
isAllowingManualCapture,
disabled,
disabledButChecked,
} ) => {
const [ isManualCaptureEnabled ] = useManualCapture();
const [ isConfirmationModalOpen, setIsConfirmationModalOpen ] = useState(
Expand All @@ -45,12 +44,10 @@ const PaymentMethodCheckbox = ( {
] = useEnabledPaymentMethodIds();
const [ , setIsStripeEnabled ] = useIsStripeEnabled();
const { isUpeEnabled } = useContext( UpeToggleContext );
const checked =
! disabled &&
( disabledButChecked || enabledPaymentMethods.includes( id ) );
const checked = ! disabled && enabledPaymentMethods.includes( id );

const handleCheckboxChange = ( hasBeenChecked ) => {
if ( disabled || disabledButChecked ) {
if ( disabled ) {
return;
}
if ( ! hasBeenChecked ) {
Expand Down Expand Up @@ -113,7 +110,7 @@ const PaymentMethodCheckbox = ( {
label={ <VisuallyHidden>{ label }</VisuallyHidden> }
onChange={ handleCheckboxChange }
checked={ checked }
disabled={ disabled || disabledButChecked }
disabled={ disabled }
/>
) }
{ isConfirmationModalOpen && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import RecurringPaymentIcon from '../../components/recurring-payment-icon';
import PaymentMethodCapabilityStatusPill from 'wcstripe/components/payment-method-capability-status-pill';
import PaymentMethodDeprecationPill from 'wcstripe/components/payment-method-deprecation-pill';
import PaymentMethodUnavailableDueConflictPill from 'wcstripe/components/payment-method-unavailable-due-conflict-pill';
import PaymentMethodRequiredForOCPill from 'wcstripe/components/payment-method-required-for-oc-pill';

const Wrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -75,10 +74,6 @@ const PaymentMethodDescription = ( {
id={ id }
label={ label }
/>
<PaymentMethodRequiredForOCPill
id={ id }
label={ label }
/>
</>
) }
</LabelWrapper>
Expand Down
6 changes: 1 addition & 5 deletions client/settings/general-settings-section/payment-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import interpolateComponents from 'interpolate-components';
import PaymentMethodsMap from '../../payment-methods-map';
import PaymentMethodDescription from './payment-method-description';
import PaymentMethodCheckbox from './payment-method-checkbox';
import { useIsOCEnabled, useManualCapture } from 'wcstripe/data';
import { useManualCapture } from 'wcstripe/data';
import {
PAYMENT_METHOD_AFFIRM,
PAYMENT_METHOD_AFTERPAY_CLEARPAY,
Expand Down Expand Up @@ -105,7 +105,6 @@ const StyledFees = styled( PaymentMethodFeesPill )`
`;

const PaymentMethod = ( { method, data } ) => {
const [ isOCEnabled ] = useIsOCEnabled();
const [ isManualCaptureEnabled ] = useManualCapture();
const paymentMethodCurrencies = usePaymentMethodCurrencies( method );

Expand Down Expand Up @@ -138,8 +137,6 @@ const PaymentMethod = ( { method, data } ) => {
// eslint-disable-next-line camelcase
wc_stripe_settings_params.has_klarna_gateway_plugin );

const isDisabledButChecked = PAYMENT_METHOD_CARD === method && isOCEnabled;

return (
<div key={ method }>
<ListElement
Expand All @@ -154,7 +151,6 @@ const PaymentMethod = ( { method, data } ) => {
label={ label }
isAllowingManualCapture={ isAllowingManualCapture }
disabled={ deprecated || isDisabled }
disabledButChecked={ isDisabledButChecked }
/>
<PaymentMethodWrapper>
<PaymentMethodDescription
Expand Down
10 changes: 10 additions & 0 deletions client/stripe-utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export const EXPRESS_PAYMENT_METHOD_SETTING_APPLE_PAY = 'applePay';
export const EXPRESS_PAYMENT_METHOD_SETTING_GOOGLE_PAY = 'googlePay';
export const EXPRESS_PAYMENT_METHOD_SETTING_LINK = 'link';

/**
* List of express payment methods
*/
export const EXPRESS_PAYMENT_METHODS = [
EXPRESS_PAYMENT_METHOD_SETTING_AMAZON_PAY,
EXPRESS_PAYMENT_METHOD_SETTING_APPLE_PAY,
EXPRESS_PAYMENT_METHOD_SETTING_GOOGLE_PAY,
EXPRESS_PAYMENT_METHOD_SETTING_LINK,
];

/**
* List of payment methods that are not recurring
*/
Expand Down
18 changes: 2 additions & 16 deletions includes/class-wc-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,7 @@ public function initialize_status_page() {

/**
* Toggle payment methods that should be enabled/disabled, e.g. unreleased,
* BNPLs when other official plugins are active,
* cards when the Optimized Checkout is enabled, etc.
* BNPLs when other official plugins are active, etc.
*
* @return void
*/
Expand All @@ -877,7 +876,6 @@ public function maybe_toggle_payment_methods() {
}

$payment_method_ids_to_disable = [];
$payment_method_ids_to_enable = [];
$enabled_payment_methods = $gateway->get_upe_enabled_payment_method_ids();

// Check for BNPLs that should be deactivated.
Expand All @@ -892,22 +890,10 @@ public function maybe_toggle_payment_methods() {
$this->maybe_deactivate_amazon_pay( $enabled_payment_methods )
);

// Check if cards should be activated.
// TODO: Remove this once card is not a requirement for the Optimized Checkout.
if ( $gateway->is_oc_enabled()
&& ! in_array( WC_Stripe_Payment_Methods::CARD, $enabled_payment_methods, true ) ) {
$payment_method_ids_to_enable[] = WC_Stripe_Payment_Methods::CARD;
}

if ( [] === $payment_method_ids_to_disable && [] === $payment_method_ids_to_enable ) {
if ( [] === $payment_method_ids_to_disable ) {
return;
}

$enabled_payment_methods = array_merge(
$enabled_payment_methods,
$payment_method_ids_to_enable
);

$gateway->update_enabled_payment_methods(
array_diff( $enabled_payment_methods, $payment_method_ids_to_disable )
);
Expand Down
19 changes: 12 additions & 7 deletions includes/constants/class-wc-stripe-payment-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ class WC_Stripe_Payment_Methods {
const LINK_LABEL = 'Link';
const PAYMENT_REQUEST_LABEL = 'Payment Request';

/**
* Payment methods that are considered as express payment methods.
*
* @var array
*/
const EXPRESS_PAYMENT_METHODS = [
self::AMAZON_PAY,
self::GOOGLE_PAY,
self::APPLE_PAY,
self::LINK,
];

/**
* Payment methods that are considered as voucher payment methods.
*
Expand Down Expand Up @@ -79,13 +91,6 @@ class WC_Stripe_Payment_Methods {
self::WECHAT_PAY,
];

const EXPRESS_PAYMENT_METHODS = [
self::AMAZON_PAY,
self::APPLE_PAY,
self::GOOGLE_PAY,
self::LINK,
];

/**
* List of express payment methods labels. Amazon Pay and Link are not included,
* as they have their own payment method classes.
Expand Down
Loading
Loading