Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions payme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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()
{
Expand All @@ -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']);
Expand Down Expand Up @@ -111,6 +113,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',
Expand Down Expand Up @@ -156,8 +164,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 = <<<FORM
<form action="{$this->checkout_url}" method="POST" id="payme_form">
Expand Down Expand Up @@ -428,9 +435,11 @@ private function PerformTransaction($payload)
"state" => 2
]
];

// Mark order as completed
$order->update_status('completed');
if ($this->complete_order === 'yes'){
// Mark order as completed
$order->update_status('completed');
}

$order->payment_complete($payload['params']['id']);

} elseif ($order->get_status() == "completed") { // handle existing Perform request
Expand Down Expand Up @@ -860,4 +869,4 @@ function payme_success_parse_request(&$wp)

/////////////// success page end

?>
?>