Skip to content

Commit 31447e9

Browse files
committed
fix: updated callback to use order key instead of transaction id
1 parent fdb5e85 commit 31447e9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/class-tradesafe.php

+5-11
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,20 @@ public static function parse_request( $wp ) {
211211

212212
// TODO: Change how signature check works.
213213

214-
$query = wc_get_orders(
215-
array(
216-
'meta_key' => 'tradesafe_transaction_id',
217-
'meta_value' => $data['id'],
218-
'meta_compare' => '=',
219-
)
220-
);
214+
$order_key = substr( $data['reference'], 0, strpos( $data['reference'], '-' ) );
215+
$order_id = wc_get_order_id_by_order_key( $order_key );
216+
$order = wc_get_order( $order_id );
221217

222-
if ( ! isset( $query[0] ) ) {
218+
if ( empty( $order ) ) {
223219
wp_die(
224-
'Invalid Transaction ID',
220+
'Invalid Order Reference',
225221
'An Error Occurred While Processing Callback',
226222
array(
227223
'code' => 400,
228224
)
229225
);
230226
}
231227

232-
$order = $query[0];
233-
234228
if ( 'FUNDS_DEPOSITED' === $data['state'] ) {
235229
$order->update_status( 'on-hold', __( 'TradeSafe is awaiting for manual EFT payment.', 'tradesafe-payment-gateway' ) );
236230

0 commit comments

Comments
 (0)