Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
30 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
4624f2f
Merge branch 'develop' into fix/removing-card-requirement-for-oc
wjrosa Aug 19, 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.8.0 - xxxx-xx-xx =
* Fix - Removes the credit card payment method requirement for the Optimized Checkout feature
* 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
* Fix - Checks for the subscription payment method (if it is Stripe) when verifying for the payment method detachment
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
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
5 changes: 2 additions & 3 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,7 +137,7 @@ const PaymentMethod = ( { method, data } ) => {
// eslint-disable-next-line camelcase
wc_stripe_settings_params.has_klarna_gateway_plugin );

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

return (
<div key={ method }>
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
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ public function get_upe_enabled_payment_method_ids( $force_refresh = false ) {
* @return string[]
*/
public function get_upe_enabled_at_checkout_payment_method_ids( $order_id = null ) {
// If the Optimized Checkout is enabled, we need to return just the card payment method.
// All payment methods are rendered inside of it.
if ( $this->oc_enabled ) {
return [ WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID ];
}

$is_automatic_capture_enabled = $this->is_automatic_capture_enabled();
$available_method_ids = [];
$account_domestic_currency = WC_Stripe::get_instance()->account->get_account_default_currency();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public function get_id() {
* @return bool
*/
public function is_enabled() {
return 'yes' === $this->enabled;
return 'yes' === $this->enabled
// When OC is enabled, we use the card payment container to render all the methods.
|| ( $this->oc_enabled && WC_Stripe_Payment_Methods::CARD === $this->stripe_id );
}

/**
Expand All @@ -185,8 +187,8 @@ public function is_enabled() {
*/
public function is_available() {
// When OC is enabled, we use the card payment container to render all the methods.
if ( $this->oc_enabled && WC_Stripe_Payment_Methods::CARD !== $this->stripe_id ) {
return false;
if ( $this->oc_enabled && WC_Stripe_Payment_Methods::CARD === $this->stripe_id ) {
return true;
}

if ( is_add_payment_method_page() && ! $this->is_reusable() ) {
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
== Changelog ==

= 9.8.0 - xxxx-xx-xx =
* Fix - Removes the credit card payment method requirement for the Optimized Checkout feature
* 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
* Fix - Checks for the subscription payment method (if it is Stripe) when verifying for the payment method detachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,6 @@ public function test_get_upe_available_payment_methods( $country, $available_pay
$this->assertSame( $available_payment_methods, $this->mock_gateway->get_upe_available_payment_methods(), "Available payment methods are not the same for $country" );
}

public function test_get_upe_enabled_at_checkout_payment_method_ids() {
$available_payment_methods = [
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID,
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
];
$this->mock_payment_method_configurations( $available_payment_methods );
$this->assertSame( $available_payment_methods, $this->mock_gateway->get_upe_enabled_at_checkout_payment_method_ids() );
}

public function get_upe_available_payment_methods_provider() {
return [
[
Expand Down Expand Up @@ -385,6 +376,60 @@ public function get_upe_available_payment_methods_provider() {
];
}

/**
* Tests for `get_upe_enabled_at_checkout_payment_method_ids`.
*
* @param array $available_methods The available payment methods.
* @param bool $oc_enabled Whether the OC feature is enabled.
* @param array $expected The expected payment method IDs.
* @return void
*
* @dataProvider provide_test_get_upe_enabled_at_checkout_payment_method_ids
*/
public function test_get_upe_enabled_at_checkout_payment_method_ids( $available_methods, $oc_enabled, $expected ) {
$this->mock_gateway->oc_enabled = $oc_enabled;

$this->mock_payment_method_configurations( $available_methods );

$actual = $this->mock_gateway->get_upe_enabled_at_checkout_payment_method_ids();

// Clean up.
$this->mock_gateway->oc_enabled = false;

$this->assertSame( $expected, $actual );
}

/**
* Data provider for `test_get_upe_enabled_at_checkout_payment_method_ids`.
*
* @return array[]
*/
public function provide_test_get_upe_enabled_at_checkout_payment_method_ids() {
return [
'Default' => [
'available methods' => [
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID,
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
],
'OC enabled' => false,
'expected' => [
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID,
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
],
],
'OC enabled' => [
'available methods (ignored)' => [
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID,
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
],
'OC enabled' => true,
'expected' => [
WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID,
],
],
];
}

/**
* CLASSIC CHECKOUT TESTS.
*/
Expand Down
18 changes: 0 additions & 18 deletions tests/phpunit/WC_Stripe_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function test_constants_defined() {
*
* @param array $active_gateways The active payment gateways.
* @param array $enabled_payment_method_ids The enabled payment method IDs.
* @param bool $oc_enabled Whether the one-click payment methods are enabled.
* @param int $update_enable_payment_methods_calls The number of times `update_enabled_payment_methods` should be called.
* @return void
*
Expand All @@ -38,7 +37,6 @@ public function test_constants_defined() {
public function test_maybe_toggle_payment_methods(
$active_gateways,
$enabled_payment_method_ids,
$oc_enabled,
$update_enable_payment_methods_calls
) {
$original_payment_gateways = WC()->payment_gateways->payment_gateways;
Expand All @@ -50,10 +48,6 @@ public function test_maybe_toggle_payment_methods(
->disableOriginalConstructor()
->getMock();

$upe_payment_gateway->expects( $this->once() )
->method( 'is_oc_enabled' )
->willReturn( $oc_enabled );

$upe_payment_gateway->expects( $this->once() )
->method( 'get_upe_enabled_payment_method_ids' )
->willReturn( $enabled_payment_method_ids );
Expand Down Expand Up @@ -88,7 +82,6 @@ public function provide_test_maybe_toggle_payment_methods() {
'enabled payment method IDs' => [
WC_Stripe_Payment_Methods::CARD,
],
'OC enabled' => false,
'update enable payment methods calls' => 0,
],
'affirm' => [
Expand All @@ -102,7 +95,6 @@ public function provide_test_maybe_toggle_payment_methods() {
WC_Stripe_Payment_Methods::CARD,
WC_Stripe_Payment_Methods::AFFIRM,
],
'OC enabled' => false,
'update enable payment methods calls' => 1,
],
'klarna' => [
Expand All @@ -116,7 +108,6 @@ public function provide_test_maybe_toggle_payment_methods() {
WC_Stripe_Payment_Methods::CARD,
WC_Stripe_Payment_Methods::KLARNA,
],
'OC enabled' => false,
'update enable payment methods calls' => 1,
],
'klarna and affirm active, but not on Stripe' => [
Expand All @@ -133,7 +124,6 @@ public function provide_test_maybe_toggle_payment_methods() {
'enabled payment method IDs' => [
WC_Stripe_Payment_Methods::CARD,
],
'OC enabled' => false,
'update enable payment methods calls' => 0,
],
'klarna and affirm active in both' => [
Expand All @@ -152,7 +142,6 @@ public function provide_test_maybe_toggle_payment_methods() {
WC_Stripe_Payment_Methods::AFFIRM,
WC_Stripe_Payment_Methods::KLARNA,
],
'OC enabled' => false,
'update enable payment methods calls' => 1,
],
'amazon pay' => [
Expand All @@ -161,13 +150,6 @@ public function provide_test_maybe_toggle_payment_methods() {
WC_Stripe_Payment_Methods::CARD,
WC_Stripe_Payment_Methods::AMAZON_PAY,
],
'OC enabled' => false,
'update enable payment methods calls' => 1,
],
'card, OC enabled' => [
'active gateways' => [],
'enabled payment method IDs' => [],
'OC enabled' => true,
'update enable payment methods calls' => 1,
],
];
Expand Down
Loading