function fn_paynl_getState($payNLTransactionID, $processor_data) { $payApiInfo = new Pay_Api_Info(); $payApiInfo->setApiToken($processor_data['processor_params']['token_api']); $payApiInfo->setServiceId($processor_data['processor_params']['service_id']); $payApiInfo->setTransactionId($payNLTransactionID); try { $result = $payApiInfo->doRequest(); } catch (Exception $ex) { fn_set_notification('E', __('error'), $ex->getMessage()); fn_redirect('/index.php?dispatch=checkout.checkout'); } $state = Pay_Helper::getStateText($result['paymentDetails']['state']); return $state; }
require 'includes/application_top.php'; require_once DIR_WS_MODULES . '/payment/paynl/Pay/Autoload.php'; $transactionId = null; $isExchange = false; if ($_REQUEST['order_id']) { $transactionId = $_REQUEST['order_id']; //exchange $isExchange = true; } else { $transactionId = $_REQUEST['orderId']; //finish $isExchange = false; } $method = $_REQUEST['method']; $payApiInfo = new Pay_Api_Info(); $payApiInfo->setApiToken(constant('MODULE_PAYMENT_PAYNL_' . $method . '_API_TOKEN')); $payApiInfo->setServiceId(constant('MODULE_PAYMENT_PAYNL_' . $method . '_SERVICE_ID')); $payApiInfo->setTransactionId($transactionId); try { $result = $payApiInfo->doRequest(); } catch (Exception $ex) { var_dump($ex->message); die; } $state = Pay_Helper::getStateText($result['paymentDetails']['state']); $orderId = $result['statsDetails']['extra1']; if ($isExchange && isAlreadyPAID($transactionId)) { die("TRUE|Already PAID"); } if (!$isExchange && isAlreadyPAID($transactionId)) { $cart =& $_SESSION['cart'];
public function processTransaction($transactionId) { $this->load->model('setting/setting'); $this->load->model('checkout/order'); $settings = $this->model_setting_setting->getSetting('paynl'); $statusPending = $settings[$this->_paymentMethodName . '_pending_status']; $statusComplete = $settings[$this->_paymentMethodName . '_completed_status']; $statusCanceled = $settings[$this->_paymentMethodName . '_canceled_status']; $transaction = $this->getTransaction($transactionId); $apiInfo = new Pay_Api_Info(); $apiInfo->setApiToken($settings[$this->_paymentMethodName . '_apitoken']); $apiInfo->setServiceId($settings[$this->_paymentMethodName . '_serviceid']); $apiInfo->setTransactionId($transactionId); $result = $apiInfo->doRequest(); $state = $result['paymentDetails']['state']; $status = self::STATUS_PENDING; $orderStatusId = $statusPending; if ($state == 100) { $status = self::STATUS_COMPLETE; $orderStatusId = $statusComplete; } else { if ($state < 0) { $status = self::STATUS_CANCELED; $orderStatusId = $statusCanceled; } } //status updaten $this->updateTransactionStatus($transactionId, $status); $message = "Pay.nl Updated order to {$status}."; //order updaten $order_info = $this->model_checkout_order->getOrder($transaction['orderId']); if ($order_info['order_status_id'] != $orderStatusId) { //alleen updaten als de status daadwerkelijk veranderd, ivm exchange, de order wordt 2 keer aangepast if ($settings[$this->_paymentMethodName . '_send_confirm_email'] == 'start') { if ($settings[$this->_paymentMethodName . '_send_status_updates'] == 1) { $send_status_update = true; } else { $send_status_update = false; } //de bevestiging is al gestuurd, dus we gaan alleen status updaten $this->model_checkout_order->update($transaction['orderId'], $orderStatusId, $message, $send_status_update); //Als de status canceled is, en het order is al confirmed, moeten de aantallen teruggeboekt worden if ($status == self::STATUS_CANCELED) { $this->putBackProducts($order_info['order_id']); } } else { // De bevestigingsmail is nog niet gestuurd, bij een cancel gaan we wel het order updaten, maar niets sturen if ($status == self::STATUS_COMPLETE) { $this->model_checkout_order->confirm($order_info['order_id'], $orderStatusId, $message, true); } else { $this->model_checkout_order->update($order_info['order_id'], $orderStatusId, $message, false); } } } return $status; }
public static function processTransaction($transactionId) { $token = Configuration::get('PAYNL_TOKEN'); $serviceId = Configuration::get('PAYNL_SERVICE_ID'); $apiInfo = new Pay_Api_Info(); $apiInfo->setApiToken($token); $apiInfo->setServiceId($serviceId); $apiInfo->setTransactionId($transactionId); $result = $apiInfo->doRequest(); $transactionAmount = $result['paymentDetails']['paidCurrenyAmount']; $stateId = $result['paymentDetails']['state']; $stateText = self::getStateText($stateId); //de transactie ophalen try { $transaction = self::getTransaction($transactionId); } catch (Pay_Exception $ex) { // transactie is niet gevonden... quickfix, we voegen hem opnieuw toe self::addTransaction($transactionId, $result['paymentDetails']['paymentOptionId'], $result['paymentDetails']['amount'], $result['paymentDetails']['paidCurrency'], str_replace('CartId: ', '', $result['statsDetails']['extra1']), 'Inserted after not found'); $transaction = self::getTransaction($transactionId); } $cartId = $orderId = $transaction['order_id']; $orderPaid = self::orderPaid($orderId); if ($orderPaid == true && $stateText != 'PAID') { throw new Pay_Exception('Order already paid'); } if ($stateText == $transaction['status']) { //nothing changed so return without changing anything $real_order_id = Order::getOrderByCartId($orderId); return array('orderId' => $orderId, 'state' => $stateText, 'real_order_id' => $real_order_id); } //update the transaction state self::updateTransactionState($transactionId, $stateText); $objOrder = Order::getOrderByCartId($cartId); //$objOrder = new Order($orderId); $statusPending = Configuration::get('PAYNL_WAIT'); $statusPaid = Configuration::get('PAYNL_SUCCESS'); $statusCancel = Configuration::get('PAYNL_CANCEL'); $id_order_state = ''; $paid = false; if ($stateText == 'PAID') { $id_order_state = $statusPaid; $module = Module::getInstanceByName(Tools::getValue('module')); $cart = new Cart($cartId); $customer = new Customer($cart->id_customer); $currency = $cart->id_currency; $orderTotal = $cart->getOrderTotal(); $extraFee = $module->getExtraCosts($transaction['option_id'], $orderTotal); $cart->additional_shipping_cost += $extraFee; $cart->save(); $paymentMethodName = $module->getPaymentMethodName($transaction['option_id']); $paidAmount = $transactionAmount / 100; $module->validateOrderPay((int) $cart->id, $id_order_state, $paidAmount, $extraFee, $paymentMethodName, NULL, array('transaction_id' => $transactionId), (int) $currency, false, $customer->secure_key); $real_order_id = Order::getOrderByCartId($cart->id); } elseif ($stateText == 'CANCEL') { $real_order_id = Order::getOrderByCartId($cartId); if ($real_order_id) { $objOrder = new Order($real_order_id); $history = new OrderHistory(); $history->id_order = (int) $objOrder->id; $history->changeIdOrderState((int) $statusCancel, $objOrder); $history->addWithemail(); } } elseif ($stateText == 'PENDING') { $id_order_state = $statusPending; $module = Module::getInstanceByName(Tools::getValue('module')); $cart = new Cart($cartId); $customer = new Customer($cart->id_customer); $currency = $cart->id_currency; $orderTotal = $cart->getOrderTotal(); $extraFee = $module->getExtraCosts($transaction['option_id'], $orderTotal); $cart->additional_shipping_cost += $extraFee; $cart->save(); $paymentMethodName = $module->getPaymentMethodName($transaction['option_id']); $paidAmount = 0; $module->validateOrderPay((int) $cart->id, $id_order_state, $paidAmount, $extraFee, $paymentMethodName, NULL, array('transaction_id' => $transactionId), (int) $currency, false, $customer->secure_key); $real_order_id = Order::getOrderByCartId($cart->id); } return array('orderId' => $orderId, 'real_order_id' => $real_order_id, 'state' => $stateText); }
public function processTransaction($transactionId) { $this->load->model('setting/setting'); $this->load->model('checkout/order'); $settings = $this->model_setting_setting->getSetting('paynl'); $statusPending = $settings[$this->_paymentMethodName . '_pending_status']; $statusComplete = $settings[$this->_paymentMethodName . '_completed_status']; $statusCanceled = $settings[$this->_paymentMethodName . '_canceled_status']; $transaction = $this->getTransaction($transactionId); $apiInfo = new Pay_Api_Info(); $apiInfo->setApiToken($settings[$this->_paymentMethodName . '_apitoken']); $apiInfo->setServiceId($settings[$this->_paymentMethodName . '_serviceid']); $apiInfo->setTransactionId($transactionId); $result = $apiInfo->doRequest(); $state = $result['paymentDetails']['state']; $status = self::STATUS_PENDING; $orderStatusId = $statusPending; if ($state == 100) { $status = self::STATUS_COMPLETE; $orderStatusId = $statusComplete; } else { if ($state < 0) { $status = self::STATUS_CANCELED; $orderStatusId = $statusCanceled; } } if ($this->isAlreadyPaid($transaction['orderId'])) { // order is al betaald, return self::STATUS_COMPLETE; } //status updaten $this->updateTransactionStatus($transactionId, $status); $message = "Pay.nl Updated order to {$status}."; //order updaten $order_info = $this->model_checkout_order->getOrder($transaction['orderId']); if ($order_info['order_status_id'] != $orderStatusId) { //alleen updaten als de status daadwerkelijk veranderd, ivm exchange, de order wordt 2 keer aangepast if ($settings[$this->_paymentMethodName . '_send_status_updates'] == 1) { $send_status_update = true; } else { $send_status_update = false; } if ($order_info['order_status_id'] == 0 && $status != self::STATUS_COMPLETE && !$send_status_update) { // hij is nog niet confirmed, we gaan hem alleen opslaan als status complete is return $status; } $this->model_checkout_order->addOrderHistory($order_info['order_id'], $orderStatusId, $message, $send_status_update); } return $status; }
private function checkStatus($order_id) { if (!class_exists('Pay_Api_Info')) { require JPATH_SITE . '/plugins/hikashoppayment/paynl/paynl/Api.php'; require JPATH_SITE . '/plugins/hikashoppayment/paynl/paynl/api/Info.php'; require JPATH_SITE . '/plugins/hikashoppayment/paynl/paynl/Helper.php'; } $payApiInfo = new Pay_Api_Info(); $payApiInfo->setApiToken($this->payment_params->token_api); $payApiInfo->setServiceId($this->payment_params->service_id); $payApiInfo->setTransactionId($order_id); try { $result = $payApiInfo->doRequest(); } catch (Exception $ex) { vmError($ex->getMessage()); } $state = Pay_Helper::getStateText($result['paymentDetails']['state']); return $state; }