Skip to content
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
fad88d6
Introducing a Stripe order helper class
wjrosa Aug 21, 2025
2ff8bac
Order meta keys as constants
wjrosa Aug 21, 2025
2f73d5e
Adding deprecation annotation
wjrosa Aug 21, 2025
2d376f5
Additional methods
wjrosa Aug 21, 2025
ce7f7ff
Replacing occurrences
wjrosa Aug 21, 2025
c8a4fa8
Unit test class
wjrosa Aug 21, 2025
ac3638b
Including class
wjrosa Aug 21, 2025
603aeab
Tests update
wjrosa Aug 21, 2025
1bf7c57
Tests update
wjrosa Aug 21, 2025
c68f45b
Replace meta key reference
wjrosa Aug 21, 2025
a754c88
Changelog and readme entries
wjrosa Aug 21, 2025
5748edc
Fix test class name
wjrosa Aug 21, 2025
bd49443
Fix test class name
wjrosa Aug 21, 2025
bff2519
validate_minimum_order_amount
wjrosa Aug 21, 2025
3875e7c
Fix tests
wjrosa Aug 22, 2025
a29267f
Order lock updates
wjrosa Aug 22, 2025
29abdf3
Order lock updates
wjrosa Aug 22, 2025
c38e781
Order lock updates
wjrosa Aug 22, 2025
8fe231c
Payment awaiting action methods
wjrosa Aug 22, 2025
e4844ee
Fix tests
wjrosa Aug 22, 2025
a9ceb2a
Merge branch 'develop' into dev/order-helper-class
wjrosa Sep 15, 2025
d750e3b
Revert unnecessary changes
wjrosa Sep 15, 2025
d69d56c
Revert unnecessary changes
wjrosa Sep 15, 2025
df37c49
Fix merge
wjrosa Sep 15, 2025
67c79d6
Update deprecated comments
wjrosa Sep 15, 2025
e7b670e
Merge branch 'develop' into dev/order-helper-class
wjrosa Sep 17, 2025
fa19b8e
Update includes/abstracts/abstract-wc-stripe-payment-gateway.php
wjrosa Sep 17, 2025
26df456
Update includes/class-wc-stripe-order-helper.php
wjrosa Sep 17, 2025
a222bca
Update includes/class-wc-stripe-order-helper.php
wjrosa Sep 17, 2025
cfe10bb
Update includes/class-wc-stripe-order-helper.php
wjrosa Sep 17, 2025
357fa89
Removing invalid tests
wjrosa Sep 17, 2025
297762c
Revert invalid method calls
wjrosa Sep 17, 2025
0ffe7b3
Update @since comment
wjrosa Sep 17, 2025
b636c2b
Update includes/class-wc-stripe-order-helper.php
wjrosa Sep 17, 2025
cf2c42d
Update includes/class-wc-stripe-order-helper.php
wjrosa Sep 17, 2025
655c2f9
Removing unused order lock param
wjrosa Sep 17, 2025
66bd3f3
Minor improvements to the refund lock code
wjrosa Sep 17, 2025
cf2546c
Adding typed params and return values + singleton pattern
wjrosa Sep 18, 2025
fd604fb
Implementing the new singleton pattern
wjrosa Sep 18, 2025
f5d10a8
Fix tests
wjrosa Sep 18, 2025
ba27b2b
Adding missing type declarations to constants
wjrosa Sep 18, 2025
9706579
Fix static implementations
wjrosa Sep 18, 2025
2aeebbd
Fix wrong lock method call
wjrosa Sep 18, 2025
9ed95f5
Merge branch 'develop' into dev/order-helper-class
wjrosa Sep 18, 2025
463fd2a
Fix static implementations
wjrosa Sep 18, 2025
7670d31
Fix static implementations
wjrosa Sep 18, 2025
305e0cb
Fix tests
wjrosa Sep 18, 2025
8d1a722
Fix remaining static calls
wjrosa Sep 18, 2025
a871fdf
Fix tests
wjrosa Sep 18, 2025
fb5c599
Fix tests
wjrosa Sep 18, 2025
7dd4763
Fix tests
wjrosa Sep 18, 2025
1dfe73e
Merge branch 'develop' into dev/order-helper-class
wjrosa Sep 18, 2025
1726d81
Merge branch 'develop' into dev/order-helper-class
wjrosa Sep 23, 2025
1f9feae
Handling source ID meta in the order helper
wjrosa Sep 23, 2025
bac9ef1
Merge branch 'develop' into dev/handling-source-id-meta
wjrosa Sep 23, 2025
8b5bbac
Handling payment intent, setup intent and refund
wjrosa Sep 23, 2025
d3797fa
Unit tests
wjrosa Sep 23, 2025
e942cb5
Changelog and readme entries
wjrosa Sep 23, 2025
e3631f3
Merge branch 'develop' into dev/handling-source-id-meta
wjrosa Sep 26, 2025
206be4f
Changelog and readme entries
wjrosa Sep 26, 2025
c095e96
Merge branch 'dev/handling-source-id-meta' of https://github.com/wooc…
wjrosa Sep 26, 2025
f683c88
Fix tests
wjrosa Sep 26, 2025
5511198
Fix changelog and readme entries
wjrosa Sep 26, 2025
a63d493
Minor test improvement
wjrosa Sep 26, 2025
a11bbcd
Handling more Stripe metas with the order helper class
wjrosa Sep 29, 2025
8d73d51
Card ID meta
wjrosa Sep 29, 2025
b264be3
UPE payment type
wjrosa Sep 29, 2025
91956e6
UPE waiting for redirect
wjrosa Sep 29, 2025
1906189
UPE redirect processed
wjrosa Sep 29, 2025
fb3a512
Merge branch 'develop' into dev/handling-more-stripe-order-metas
wjrosa Oct 1, 2025
bc8a456
Fix tests
wjrosa Oct 1, 2025
ffef3da
Fix method implementation + remove unused method
wjrosa Oct 1, 2025
5ddc294
Changelog and readme entries
wjrosa Oct 1, 2025
7853153
Merge branch 'develop' into dev/handling-more-stripe-order-metas
wjrosa Oct 6, 2025
e56b0cc
Merge branch 'develop' into dev/handling-more-stripe-order-metas
daledupreez Oct 7, 2025
265d63a
Merge branch 'develop' into dev/handling-more-stripe-order-metas
wjrosa Oct 8, 2025
368a34f
Update includes/class-wc-stripe-order-helper.php
wjrosa Oct 8, 2025
c77fab6
Fix implementation after method renaming + renaming the card_id metho…
wjrosa Oct 8, 2025
8f8960e
Update includes/class-wc-stripe-order-helper.php
wjrosa Oct 8, 2025
10125f0
Changing null check
wjrosa Oct 8, 2025
aff3db9
New protected method to handle meta update
wjrosa Oct 8, 2025
29b7ab8
Renaming Order Helper methods to append _id
wjrosa Oct 8, 2025
1b18de3
Changelog and readme entries
wjrosa Oct 8, 2025
3f46ddc
Merge branch 'develop' into dev/renaming-order-helper-methods-to-appe…
wjrosa Oct 14, 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
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*** Changelog ***

= 10.0.0 - xxxx-xx-xx =
* Dev - Renames previous Order Helper class methods to use the `_id` suffix
* Dev - Expands the Stripe Order Helper class to handle customer ID, card ID, UPE payment type, and UPE redirect status metas
* Update - Removes frontend code related to Payment Request Buttons in the checkout page
* Update - Disable Payment Request Buttons and ensure Express Checkout is used when express checkout buttons are enabled
* Dev - Expands the Stripe Order Helper class to handle source ID, refund ID, intent ID, and setup intent ID metas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,13 @@ public function process_payment( $order_id, $retry = true, $force_save_save = fa

$intent = $this->create_or_update_payment_intent( $order );

$order->update_meta_data( '_stripe_upe_payment_type', $this->stripe_id );
$order_helper = WC_Stripe_Order_Helper::get_instance();

$order_helper->update_stripe_upe_payment_type( $order, $this->stripe_id );
$order->update_status( OrderStatus::PENDING, __( 'Awaiting payment.', 'woocommerce-gateway-stripe' ) );
$order->save();

WC_Stripe_Order_Helper::get_instance()->add_payment_intent_to_order( $intent->id, $order );
$order_helper->add_payment_intent_to_order( $intent->id, $order );

return [
'result' => 'success',
Expand Down Expand Up @@ -386,7 +388,7 @@ public function update_payment_intent_ajax() {
$intent = $this->create_or_update_payment_intent( $order );

$order->update_status( OrderStatus::PENDING, __( 'Awaiting payment.', 'woocommerce-gateway-stripe' ) );
$order->update_meta_data( '_stripe_upe_payment_type', $this->stripe_id );
WC_Stripe_Order_Helper::get_instance()->update_stripe_upe_payment_type( $order, $this->stripe_id );
$order->save();

wp_send_json(
Expand Down
26 changes: 14 additions & 12 deletions includes/abstracts/abstract-wc-stripe-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function maybe_remove_non_existent_customer( $error, $order ) {
}

delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
$order->delete_meta_data( '_stripe_customer_id' );
WC_Stripe_Order_Helper::get_instance()->delete_stripe_customer_id( $order );
$order->save();

return true;
Expand Down Expand Up @@ -410,7 +410,7 @@ public function get_transaction_url( $order ) {
*/
public function get_stripe_customer_id( $order ) {
// Try to get it via the order first.
$customer = $order->get_meta( '_stripe_customer_id', true );
$customer = WC_Stripe_Order_Helper::get_instance()->get_stripe_customer_id( $order );

if ( empty( $customer ) ) {
$customer = get_user_option( '_stripe_customer_id', $order->get_customer_id() );
Expand Down Expand Up @@ -1021,14 +1021,14 @@ public function prepare_order_source( $order = null ) {
}

$order_helper = WC_Stripe_Order_Helper::get_instance();
$source_id = $order_helper->get_stripe_source( $order );
$source_id = $order_helper->get_stripe_source_id( $order );

// Since 4.0.0, we changed card to source so we need to account for that.
if ( empty( $source_id ) ) {
$source_id = $order->get_meta( '_stripe_card_id', true );
$source_id = $order_helper->get_stripe_card_id( $order );

// Take this opportunity to update the key name.
$order_helper->update_stripe_source( $order, $source_id );
$order_helper->update_stripe_source_id( $order, $source_id );

if ( is_callable( [ $order, 'save' ] ) ) {
$order->save();
Expand Down Expand Up @@ -1079,13 +1079,15 @@ public function check_source( $prepared_source ) {
* @param stdClass $source Source information.
*/
public function save_source_to_order( $order, $source ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();

// Store source in the order.
if ( $source->customer ) {
$order->update_meta_data( '_stripe_customer_id', $source->customer );
$order_helper->update_stripe_customer_id( $order, $source->customer );
}

if ( $source->source ) {
WC_Stripe_Order_Helper::get_instance()->update_stripe_source( $order, $source->source );
$order_helper->update_stripe_source_id( $order, $source->source );
}

if ( is_callable( [ $order, 'save' ] ) ) {
Expand Down Expand Up @@ -1279,7 +1281,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
}
}

$order_helper->update_stripe_refund( $order, $response->id );
$order_helper->update_stripe_refund_id( $order, $response->id );

if ( isset( $response->balance_transaction ) ) {
$this->update_fees( $order, $response->balance_transaction );
Expand Down Expand Up @@ -1702,7 +1704,7 @@ public function save_intent_to_order( $order, $intent ) {
$order->update_meta_data( '_stripe_mandate_id', $charge->payment_method_details->acss_debit->mandate );
}
} elseif ( 'setup_intent' === $intent->object ) {
$order_helper->update_stripe_setup_intent( $order, $intent->id );
$order_helper->update_stripe_setup_intent_id( $order, $intent->id );

// Add mandate for free trial subscriptions.
if ( isset( $intent->mandate ) ) {
Expand All @@ -1724,13 +1726,13 @@ public function save_intent_to_order( $order, $intent ) {
*/
public function get_intent_from_order( $order ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();
$intent_id = $order_helper->get_stripe_intent( $order );
$intent_id = $order_helper->get_stripe_intent_id( $order );
if ( $intent_id ) {
return $this->get_intent( 'payment_intents', $intent_id );
}

// The order doesn't have a payment intent, but it may have a setup intent.
$intent_id = $order_helper->get_stripe_setup_intent( $order );
$intent_id = $order_helper->get_stripe_setup_intent_id( $order );
if ( $intent_id ) {
return $this->get_intent( 'setup_intents', $intent_id );
}
Expand Down Expand Up @@ -1919,7 +1921,7 @@ public function setup_intent( $order, $prepared_source ) {
if ( is_wp_error( $setup_intent ) ) {
WC_Stripe_Logger::log( "Unable to create SetupIntent for Order #$order_id: " . print_r( $setup_intent, true ) );
} elseif ( WC_Stripe_Intent_Status::REQUIRES_ACTION === $setup_intent->status ) {
WC_Stripe_Order_Helper::get_instance()->update_stripe_setup_intent( $order, $setup_intent->id );
WC_Stripe_Order_Helper::get_instance()->update_stripe_setup_intent_id( $order, $setup_intent->id );
$order->save();

return $setup_intent->client_secret;
Expand Down
6 changes: 4 additions & 2 deletions includes/admin/class-wc-rest-stripe-orders-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ public function create_customer( $request ) {
}
$customer = new WC_Stripe_Customer( $order_user->ID );

$order_helper = WC_Stripe_Order_Helper::get_instance();

// Set the customer ID if known but not already set.
$customer_id = $order->get_meta( '_stripe_customer_id', true );
$customer_id = $order_helper->get_stripe_customer_id( $order );
if ( ! $customer->get_id() && $customer_id ) {
$customer->set_id( $customer_id );
}
Expand All @@ -143,7 +145,7 @@ public function create_customer( $request ) {
return new WP_Error( 'stripe_error', $e->getMessage() );
}

$order->update_meta_data( '_stripe_customer_id', $customer_id );
$order_helper->update_stripe_customer_id( $order, $customer_id );
$order->save();

return rest_ensure_response( [ 'id' => $customer_id ] );
Expand Down
23 changes: 12 additions & 11 deletions includes/admin/class-wc-stripe-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function order_data_exporter( $email_address, $page = 1 ) {
$done = false;
$data_to_export = [];
$orders = $this->get_stripe_orders( $email_address, (int) $page );
$order_helper = WC_Stripe_Order_Helper::get_instance();
$done = true;
if ( 0 < count( $orders ) ) {
foreach ( $orders as $order ) {
Expand All @@ -130,11 +131,11 @@ public function order_data_exporter( $email_address, $page = 1 ) {
'data' => [
[
'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
'value' => WC_Stripe_Order_Helper::get_instance()->get_stripe_source( $order ),
'value' => $order_helper->get_stripe_source_id( $order ),
],
[
'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
'value' => $order->get_meta( '_stripe_customer_id', true ),
'value' => $order_helper->get_stripe_customer_id( $order ),
],
],
];
Expand Down Expand Up @@ -366,9 +367,9 @@ protected function maybe_handle_subscription( $order ) {
$renewal_orders = class_exists( 'WC_Subscriptions_Renewal_Order' ) ? WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id(), 'WC_Order' ) : [];
foreach ( $renewal_orders as $renewal_order ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();
$order_helper->delete_stripe_source( $renewal_order );
$order_helper->delete_stripe_refund( $renewal_order );
$renewal_order->delete_meta_data( '_stripe_customer_id' );
$order_helper->delete_stripe_source_id( $renewal_order );
$order_helper->delete_stripe_refund_id( $renewal_order );
$order_helper->delete_stripe_customer_id( $renewal_order );
}

$subscription->delete_meta_data( '_stripe_source_id' );
Expand All @@ -386,9 +387,9 @@ protected function maybe_handle_subscription( $order ) {
*/
protected function maybe_handle_order( $order ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();
$stripe_source_id = $order_helper->get_stripe_source( $order );
$stripe_refund_id = $order_helper->get_stripe_refund( $order );
$stripe_customer_id = $order->get_meta( '_stripe_customer_id', true );
$stripe_source_id = $order_helper->get_stripe_source_id( $order );
$stripe_refund_id = $order_helper->get_stripe_refund_id( $order );
$stripe_customer_id = $order_helper->get_stripe_customer_id( $order );

if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) {
/* translators: %d Order ID */
Expand All @@ -399,9 +400,9 @@ protected function maybe_handle_order( $order ) {
return [ false, false, [] ];
}

$order_helper->delete_stripe_source( $order );
$order_helper->delete_stripe_refund( $order );
$order->delete_meta_data( '_stripe_customer_id' );
$order_helper->delete_stripe_source_id( $order );
$order_helper->delete_stripe_refund_id( $order );
$order_helper->delete_stripe_customer_id( $order );

return [ true, false, [ __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ] ];
}
Expand Down
10 changes: 5 additions & 5 deletions includes/class-wc-stripe-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ private static function should_load_scripts_for_prb_location( $location ) {
*/
public static function add_payment_intent_to_order( $payment_intent_id, $order ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();
$old_intent_id = $order_helper->get_stripe_intent( $order );
$old_intent_id = $order_helper->get_stripe_intent_id( $order );
if ( $old_intent_id === $payment_intent_id ) {
return;
}
Expand All @@ -1318,7 +1318,7 @@ public static function add_payment_intent_to_order( $payment_intent_id, $order )
)
);

$order_helper->update_stripe_intent( $order, $payment_intent_id );
$order_helper->update_stripe_intent_id( $order, $payment_intent_id );
$order->save();
}

Expand Down Expand Up @@ -1421,9 +1421,9 @@ public static function get_payment_method_from_intent( $intent ) {
*/
public static function get_intent_id_from_order( $order ) {
$order_helper = WC_Stripe_Order_Helper::get_instance();
$intent_id = $order_helper->get_stripe_intent( $order );
$intent_id = $order_helper->get_stripe_intent_id( $order );
if ( ! $intent_id ) {
$intent_id = $order_helper->get_stripe_setup_intent( $order );
$intent_id = $order_helper->get_stripe_setup_intent_id( $order );
}

return $intent_id ?? false;
Expand Down Expand Up @@ -1968,7 +1968,7 @@ public static function validate_intent_for_order( $order, $intent, ?string $sele
}

if ( null === $selected_payment_type ) {
$selected_payment_type = $order->get_meta( '_stripe_upe_payment_type', true );
$selected_payment_type = WC_Stripe_Order_Helper::get_instance()->get_stripe_upe_payment_type( $order );
}

// If we don't have a selected payment type, that implies we have no stored value and a new payment type is permitted.
Expand Down
6 changes: 3 additions & 3 deletions includes/class-wc-stripe-intent-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function verify_intent() {
}

// Validate the intent being verified.
$order_intent_id = WC_Stripe_Order_Helper::get_instance()->get_stripe_intent( $order );
$order_intent_id = WC_Stripe_Order_Helper::get_instance()->get_stripe_intent_id( $order );
if ( ! $order_intent_id || ! isset( $_GET['intent_id'] ) || $order_intent_id !== $_GET['intent_id'] ) {
throw new WC_Stripe_Exception( 'invalid_intent', __( "We're not able to process this payment. Please try again later.", 'woocommerce-gateway-stripe' ) );
}
Expand Down Expand Up @@ -525,7 +525,7 @@ public function update_intent( $intent_id = '', $order_id = null, $save_payment_
WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID,
];
}
$order->update_meta_data( '_stripe_upe_payment_type', $selected_upe_payment_type );
$order_helper->update_stripe_upe_payment_type( $order, $selected_upe_payment_type );
}
if ( ! empty( $customer ) && $customer->get_id() ) {
$request['customer'] = $customer->get_id();
Expand Down Expand Up @@ -886,7 +886,7 @@ public function create_and_confirm_payment_intent( $payment_information ) {

// Only update the payment_type if we have a reference to the payment type the customer selected.
if ( '' !== $selected_payment_type ) {
$order->update_meta_data( '_stripe_upe_payment_type', $selected_payment_type );
WC_Stripe_Order_Helper::get_instance()->update_stripe_upe_payment_type( $order, $selected_payment_type );
}

return $payment_intent;
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-stripe-order-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function process_redirect_payment( $order_id, $retry = true, $previous_er
// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
if ( $this->is_no_such_customer_error( $response->error ) ) {
delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
$order->delete_meta_data( '_stripe_customer_id' );
$order_helper->delete_stripe_customer_id( $order );
$order->save();
}

Expand Down
Loading
Loading