From 5b924d2c4044898476be312174581ee383a24d10 Mon Sep 17 00:00:00 2001 From: Lipatov Yuriy Date: Fri, 17 Apr 2020 15:49:04 +0300 Subject: [PATCH 1/3] Add able to set "Order auto complete" setting New feature for change after success order behavior. Now you able to set "Order auto complete" or maually change order status after delivery products to customer. --- payme.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/payme.php b/payme.php index d769baa..7d601ab 100644 --- a/payme.php +++ b/payme.php @@ -3,7 +3,7 @@ Plugin Name: Payme Plugin URI: http://paycom.uz Description: Payme Checkout Plugin for WooCommerce -Version: 1.4.6 +Version: 1.4.8 Author: richman@mail.ru, support@paycom.uz Text Domain: payme */ @@ -111,6 +111,12 @@ public function init_form_fields() 'label' => __('Enabled', 'payme'), 'default' => 'yes' ], + 'complete_order' => [ + 'title' => __('Order auto complete', 'payme'), + 'type' => 'checkbox', + 'label' => __('If disabled, you have to manually change order status to COMPLETE after success payment', 'payme'), + 'default' => 'yes' + ], 'merchant_id' => [ 'title' => __('Merchant ID', 'payme'), 'type' => 'text', @@ -156,8 +162,7 @@ public function generate_form($order_id) $label_pay = __('Pay', 'payme'); $label_cancel = __('Cancel payment and return back', 'payme'); - - $callbackUrl=$this->return_url.'&order_id='.$order_id; + $callbackUrl=$this->return_url.'/'.$order_id.'/?key='.$order->get_order_key(); $form = <<
@@ -428,9 +433,10 @@ private function PerformTransaction($payload) "state" => 2 ] ]; - - // Mark order as completed - $order->update_status('completed'); + if ($this->complete_order){ + // Mark order as completed + $order->update_status('completed'){ + } $order->payment_complete($payload['params']['id']); } elseif ($order->get_status() == "completed") { // handle existing Perform request @@ -860,4 +866,4 @@ function payme_success_parse_request(&$wp) /////////////// success page end -?> \ No newline at end of file +?> From 91c1c0736313ce08f0e4973eec948d5c99914606 Mon Sep 17 00:00:00 2001 From: Lipatov Yuriy Date: Fri, 17 Apr 2020 16:34:54 +0300 Subject: [PATCH 2/3] Update payme.php --- payme.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/payme.php b/payme.php index 7d601ab..9215ad9 100644 --- a/payme.php +++ b/payme.php @@ -46,7 +46,8 @@ class WC_PAYME extends WC_Payment_Gateway protected $merchant_id; protected $merchant_key; protected $checkout_url; - protected $return_url; + protected $return_url; + protected $complete_order; public function __construct() { @@ -64,7 +65,8 @@ public function __construct() $this->merchant_id = $this->get_option('merchant_id'); $this->merchant_key = $this->get_option('merchant_key'); $this->checkout_url = $this->get_option('checkout_url'); - $this->return_url = $this->get_option('return_url'); + $this->return_url = $this->get_option('return_url'); + $this->complete_order = $this->get_option('complete_order'); add_action('woocommerce_receipt_' . $this->id, [$this, 'receipt_page']); add_action('woocommerce_update_options_payment_gateways_' . $this->id, [$this, 'process_admin_options']); @@ -433,7 +435,7 @@ private function PerformTransaction($payload) "state" => 2 ] ]; - if ($this->complete_order){ + if ($this->complete_order === 'yes'){ // Mark order as completed $order->update_status('completed'){ } From 94c6c337554705326153f6bc537bdb4542d12eac Mon Sep 17 00:00:00 2001 From: Lipatov Yuriy Date: Fri, 17 Apr 2020 16:38:32 +0300 Subject: [PATCH 3/3] Update payme.php --- payme.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/payme.php b/payme.php index 9215ad9..7a4b379 100644 --- a/payme.php +++ b/payme.php @@ -437,8 +437,9 @@ private function PerformTransaction($payload) ]; if ($this->complete_order === 'yes'){ // Mark order as completed - $order->update_status('completed'){ + $order->update_status('completed'); } + $order->payment_complete($payload['params']['id']); } elseif ($order->get_status() == "completed") { // handle existing Perform request