diff --git a/pointcheckout_pointcheckoutpay/classes/class-woocommerce-pointcheckout.php b/pointcheckout_pointcheckoutpay/classes/class-woocommerce-pointcheckout.php index 8aad3c0..858ec2d 100755 --- a/pointcheckout_pointcheckoutpay/classes/class-woocommerce-pointcheckout.php +++ b/pointcheckout_pointcheckoutpay/classes/class-woocommerce-pointcheckout.php @@ -17,7 +17,8 @@ public function __construct() } // Define user set variables - $this->title = 'PointCheckout'; + $this->method_title = __( 'PointCheckout', 'woocommerce' ); + $this->title ='PointCheckout'; $this->description = __('Pay for your cart using PointCheckout payment method '.' more details about PointCheckout?', 'pointcheckout_pointcheckoutpay'); $this->pfConfig = PointCheckout_PointCheckoutPay_Config::getInstance(); $this->pfPayment = PointCheckout_PointCheckoutPay_Payment::getInstance(); @@ -30,7 +31,7 @@ public function __construct() // Save options add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); - add_action('woocommerce_wc_gateway_pointcheckout_process_response', array(&$this, 'process_response')); + add_action('woocommerce_wc_gateway_pointcheckout_process_response', array($this, 'process_response')); } function process_admin_options() { @@ -276,7 +277,9 @@ function process_payment($order_id) update_post_meta($order->id, '_payment_method', POINTCHECKOUT_PAY_PAYMENT_METHOD); } $form = $this->pfPayment->getPaymentRequestForm(); - $result = array('result' => 'success', 'form' => $form); + $note = $this->pfPayment->getPointCheckoutOrderHistoryMessage($form['response']->result->checkoutId, 0, $form['response']->result->status, ''); + $order->add_order_note( $note ); + $result = array('result' => 'success', 'form' => $form['form']); if (isset($_POST['woocommerce_pay']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-pay')) { wp_send_json($result); exit; @@ -301,14 +304,12 @@ private function _handleResponse() $order = wc_get_order($_REQUEST['reference']); if ($success['success']) { $order->payment_complete(); - $order->add_order_note('PointCheckout payment confirmed'); WC()->session->set('refresh_totals', true); $redirectUrl = $this->get_return_url($order); } else { $redirectUrl = esc_url($woocommerce->cart->get_checkout_url()); $order->cancel_order(); - $order->add_order_note('PointCheckout payment Failed'); } echo ''; exit; diff --git a/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Config.php b/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Config.php index 42c16d0..cdf1722 100755 --- a/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Config.php +++ b/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Config.php @@ -15,15 +15,13 @@ class PointCheckout_PointCheckoutPay_Config extends PointCheckout_PointCheckoutP private $Api_Key; private $command; private $Mode; - private $gatewayCurrency; - private $successOrderStatusId; private $orderPlacement; - private $status; private $logFileDir; private $allowSpecific; private $specific_countries; private $allowUserSpecific; private $specific_uesr_roles; + private $new_order_status; public function __construct() @@ -39,14 +37,12 @@ public function __construct() $this->command = $this->_getShoppingCartConfig('command'); $this->Api_Secret = $this->_getShoppingCartConfig('Api_Secret'); $this->Mode = $this->_getShoppingCartConfig('mode'); - $this->gatewayCurrency = 'base'; - $this->successOrderStatusId = ''; $this->orderPlacement = $this->_getShoppingCartConfig('order_placement'); - $this->status = $this->enabled; $this->allowSpecific = $this->_getShoppingCartConfig('allow_specific'); $this->specific_countries = $this->_getShoppingCartConfig('specific_countries'); $this->allowUserSpecific = $this->_getShoppingCartConfig('allow_user_specific'); - $this->specific_uesr_roles = $this->_getShoppingCartConfig('specific_user_roles'); + $this->specific_uesr_roles = $this->_getShoppingCartConfig('specific_user_roles'); + $this->new_order_status = $this->_getShoppingCartConfig('new_order_status'); } /** @@ -83,11 +79,7 @@ public function getMode() } - public function getGatewayCurrency() - { - return $this->gatewayCurrency; - } - + public function getSuccessOrderStatusId() @@ -95,10 +87,7 @@ public function getSuccessOrderStatusId() return $this->successOrderStatusId; } - public function getStatus() - { - return $this->status; - } + public function isActive() { @@ -124,6 +113,13 @@ public function getSpecificUserRoles(){ return $this->specific_uesr_roles; } + + public function getNewOrderStatus(){ + return $this->new_order_status; + } + + + public function getOrderPlacement() { return $this->orderPlacement; diff --git a/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Payment.php b/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Payment.php index 1858345..22f8376 100755 --- a/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Payment.php +++ b/pointcheckout_pointcheckoutpay/lib/pointcheckout/classes/Payment.php @@ -29,8 +29,9 @@ public static function getInstance() public function getPaymentRequestParams() { $orderId = $this->pfOrder->getSessionOrderId(); - $order = wc_get_order($orderId); + $order = new WC_order($orderId); $this->pfOrder->loadOrder($orderId); + $order->update_status($this->pfConfig->getNewOrderStatus()); $gatewayParams = array( 'referenceId' => $orderId, @@ -94,7 +95,10 @@ public function getPaymentRequestParams() */ public function getPaymentRequestForm() { - + + if(!$this->pfConfig->isEnabled()){ + return null; + } $paymentRequestParams = $this->getPaymentRequestParams(); $response = $this->PointCheckoutApiCall($paymentRequestParams); if (($response->success == 'true' && $response->result->checkoutKey != null )) { @@ -109,7 +113,12 @@ public function getPaymentRequestForm() $this->pfOrder->clearSessionCurrentOrder(); $form = '