From d598dc507c8482cd84bf7078a3304ef785e4b6c0 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Thu, 1 Jun 2017 08:05:16 +0200 Subject: [PATCH 1/3] Do not process orders automatically --- .../abstract-wc-gateway-ppec-paypal-request-handler.php | 9 ++++++++- readme.txt | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php b/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php index df943112..4873a41e 100644 --- a/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php +++ b/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php @@ -73,7 +73,14 @@ protected function get_paypal_order( $raw_custom ) { */ protected function payment_complete( $order, $txn_id = '', $note = '' ) { $order->add_order_note( $note ); - $order->payment_complete( $txn_id ); + + if ( ! empty( $txn_id ) ) { + $order->set_transaction_id( $txn_id ); + } + + if ( ! $order->get_date_paid( 'edit' ) ) { + $order->set_date_paid( current_time( 'timestamp', true ) ); + } } /** diff --git a/readme.txt b/readme.txt index 50ec8578..8d9470af 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, mikaey, fullysupportedphil, dsmithweb, corsonr, bor0, zandyring Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal Requires at least: 4.4 -Tested up to: 4.4 +Tested up to: 4.7 Stable tag: 1.3.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -89,6 +89,7 @@ https://gist.github.com/mikejolley/ad2ecc286c9ad6cefbb7065ba6dfef48 * Fix - Fatal Error calling is_main_query. * Fix - Customer invoice email doesn't allow payment with PPEC. * Fix - Double stock reduction. +* Fix - Payment automatically goes to complete when payment action set to Authorize. = 1.2.1 = * Fix - Avoid plugin links notice when WooCommerce is not active - props rellect From 0a620f15372014867e39f8afabac48b3a5fc7863 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Mon, 5 Jun 2017 10:10:57 +0200 Subject: [PATCH 2/3] Update PR per woocommerce/pull/15402 --- .../abstract-wc-gateway-ppec-paypal-request-handler.php | 9 +-------- includes/class-wc-gateway-ppec-ipn-handler.php | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php b/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php index 4873a41e..df943112 100644 --- a/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php +++ b/includes/abstracts/abstract-wc-gateway-ppec-paypal-request-handler.php @@ -73,14 +73,7 @@ protected function get_paypal_order( $raw_custom ) { */ protected function payment_complete( $order, $txn_id = '', $note = '' ) { $order->add_order_note( $note ); - - if ( ! empty( $txn_id ) ) { - $order->set_transaction_id( $txn_id ); - } - - if ( ! $order->get_date_paid( 'edit' ) ) { - $order->set_date_paid( current_time( 'timestamp', true ) ); - } + $order->payment_complete( $txn_id ); } /** diff --git a/includes/class-wc-gateway-ppec-ipn-handler.php b/includes/class-wc-gateway-ppec-ipn-handler.php index 8d01a5ea..19718c3b 100644 --- a/includes/class-wc-gateway-ppec-ipn-handler.php +++ b/includes/class-wc-gateway-ppec-ipn-handler.php @@ -97,7 +97,7 @@ public function handle_valid_ipn( $posted_data ) { $posted_data['payment_status'] = strtolower( $posted_data['payment_status'] ); // Sandbox fix. - if ( isset( $posted_data['test_ipn'] ) && 1 == $posted_data['test_ipn'] && 'pending' == $posted_data['payment_status'] ) { + if ( isset( $posted_data['test_ipn'], $posted_data['pending_reason'] ) && 'authorization' !== $posted_data['pending_reason'] && 1 == $posted_data['test_ipn'] && 'pending' == $posted_data['payment_status'] ) { $posted_data['payment_status'] = 'completed'; } From 7db9ace3fbc3bd77f6a06f14fad01a6e77e33fa5 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Mon, 5 Jun 2017 14:32:27 +0200 Subject: [PATCH 3/3] Alter conditional --- includes/class-wc-gateway-ppec-ipn-handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-gateway-ppec-ipn-handler.php b/includes/class-wc-gateway-ppec-ipn-handler.php index 19718c3b..9c54e569 100644 --- a/includes/class-wc-gateway-ppec-ipn-handler.php +++ b/includes/class-wc-gateway-ppec-ipn-handler.php @@ -97,7 +97,7 @@ public function handle_valid_ipn( $posted_data ) { $posted_data['payment_status'] = strtolower( $posted_data['payment_status'] ); // Sandbox fix. - if ( isset( $posted_data['test_ipn'], $posted_data['pending_reason'] ) && 'authorization' !== $posted_data['pending_reason'] && 1 == $posted_data['test_ipn'] && 'pending' == $posted_data['payment_status'] ) { + if ( ( empty( $posted_data['pending_reason'] ) || 'authorization' !== $posted_data['pending_reason'] ) && isset( $posted_data['test_ipn'] ) && 1 == $posted_data['test_ipn'] && 'pending' == $posted_data['payment_status'] ) { $posted_data['payment_status'] = 'completed'; }