From fa222f018b85bc906e1cbb3a04c6921cc02a8ea9 Mon Sep 17 00:00:00 2001 From: Skylar L Date: Thu, 13 Jun 2019 09:26:58 -0400 Subject: [PATCH] check for duplicate order upon paypal express return --- classes/wc-gateway-paypal-express-angelleye.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index c7840a6ef..f8f550884 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -1596,8 +1596,14 @@ public function process_payment($order_id) { if (!empty($_POST['wc-paypal_express-payment-token']) && $_POST['wc-paypal_express-payment-token'] != 'new') { $result = $this->angelleye_ex_doreference_transaction($order_id); if (!empty($result['ACK']) && $result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning') { - $order->payment_complete($result['TRANSACTIONID']); - $order->add_order_note(sprintf(__('%s payment approved! Transaction ID: %s', 'paypal-for-woocommerce'), $this->title, $result['TRANSACTIONID'])); + // @note Skylar L check for duplicate order + if ($result['ACK'] == 'SuccessWithWarning' && !empty($result['L_ERRORCODE0']) && '11607' == $result['L_ERRORCODE0']) { + $order->update_status('on-hold', empty($result['L_LONGMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : $result['L_LONGMESSAGE0']); + } + else { + $order->payment_complete($result['TRANSACTIONID']); + $order->add_order_note(sprintf(__('%s payment approved! Transaction ID: %s', 'paypal-for-woocommerce'), $this->title, $result['TRANSACTIONID'])); + } WC()->cart->empty_cart(); return array( 'result' => 'success',