Skip to content

Commit 9b931ab

Browse files
wjrosadiegocurbelo
andcommitted
Fix get order signature method when order is invalid (#4075)
* Fix get order signature method when order is invalid * Changelog and readme entries * Update PHPDoc --------- Co-authored-by: Diego Curbelo <[email protected]>
1 parent 9a5a96b commit 9b931ab

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fix - Temporarily disables the subscriptions detached notice feature due to long loading times on stores with many subscriptions.
55
* Fix - Update ACH capability check key
66
* Fix - Update legacy checkout documentation links and deprecation notice display logic
7+
* Fix - Fixes an issue where the order signature retrieval method could throw a fatal error when the received order parameter is actually an OrderRefund object (instead of a WC_Order).
78
* Fix - Fixes an error with the `filter_thankyou_order_received_text` filter when it does not receive a valid WC_Order instance.
89

910
= 9.3.0 - 2025-03-13 =

includes/abstracts/abstract-wc-stripe-payment-gateway.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Automattic\WooCommerce\Admin\Overrides\OrderRefund;
4+
25
if ( ! defined( 'ABSPATH' ) ) {
36
exit;
47
}
@@ -2389,10 +2392,12 @@ public function get_balance_transaction_id_from_charge( $charge ) {
23892392
*
23902393
* This signature is included as metadata in Stripe requests and used to identify the order when webhooks are received.
23912394
*
2392-
* @param WC_Order $order The Order object.
2395+
* @param WC_Order|OrderRefund $order The Order object.
23932396
* @return string The order's unique signature. Format: order_id:md5(order_id-order_key-customer_id-order_total).
23942397
*/
23952398
protected function get_order_signature( $order ) {
2399+
$order = ! is_a( $order, 'WC_Order' ) ? wc_get_order( $order ) : $order;
2400+
23962401
$signature = [
23972402
absint( $order->get_id() ),
23982403
$order->get_order_key(),

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
114114
* Fix - Temporarily disables the subscriptions detached notice feature due to long loading times on stores with many subscriptions.
115115
* Fix - Update ACH capability check key
116116
* Fix - Update legacy checkout documentation links and deprecation notice display logic
117+
* Fix - Fixes an issue where the order signature retrieval method could throw a fatal error when the received order parameter is actually an OrderRefund object (instead of a WC_Order).
117118
* Fix - Fixes an error with the `filter_thankyou_order_received_text` filter when it does not receive a valid WC_Order instance.
118119

119120
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 commit comments

Comments
 (0)