コード例 #1
0
 protected function finalizeOrder(\Payin7\Models\OrderModel $order)
 {
     $this->module->getLogger()->info(get_class($this) . ': orderfinalize :: ' . print_r($_POST, true));
     /** @noinspection PhpUndefinedMethodInspection */
     $order_data = array('orderId' => $order->getPayin7OrderIdentifier(), 'orderUrl' => $this->module->getFrontendOrderCompleteUrl($order, false, $this->module->getShouldUseSecureConnection(), true), 'cancelUrl' => $this->module->getModuleLink('ordercancel', array('module_action' => 'cancel'), $this->module->getShouldUseSecureConnection(), 'ordercancel_handler'), 'completeUrl' => $this->module->getModuleLink('ordersuccess', array('module_action' => 'complete'), $this->module->getShouldUseSecureConnection(), 'ordersuccess_handler'), 'isCheckout' => true);
     $this->context->smarty->assign(array_merge($this->module->getPayin7SDKTemplateParams(), array('order_data' => json_encode($order_data))));
     if ($this->module->getIsPrestashop14()) {
         $this->context->smarty->display(_PS_MODULE_DIR_ . 'payin7/views/templates/front/finalize.tpl');
     } else {
         return $this->setTemplate('finalize.tpl');
     }
     return null;
 }
コード例 #2
0
 protected function processOrderStateChange($new_order_state, array $payload, \Payin7\Models\OrderModel $order, &$message, &$code)
 {
     $ret = true;
     $message = null;
     $code = null;
     switch ($new_order_state) {
         case 'cancel':
             /** @var OrderCore $orderm */
             /** @noinspection PhpUndefinedClassInspection */
             $orderm = new Order($order->getOrderId());
             if (ValidateCore::isLoadedObject($orderm)) {
                 $state = $orderm->current_state;
                 if ($state == $this->module->getConfigIdOrderStatePending()) {
                     // temporarily disable updating history back to Payin7
                     $this->module->setHistoryUpdateEnabled(false);
                     $orderm->setCurrentState($this->module->getConfigIdOrderStateCancelled());
                     // reenable history
                     $this->module->setHistoryUpdateEnabled(true);
                     $message = 'Local order state set to (1): ' . $this->module->getConfigIdOrderStateCancelled();
                 }
             } else {
                 $message = 'Local order could not be loaded (2)';
                 $ret = false;
             }
             break;
         case 'active':
             $is_verified = isset($payload['is_verified']) ? (bool) $payload['is_verified'] : false;
             $is_paid = isset($payload['is_paid']) ? (bool) $payload['is_paid'] : false;
             // update the order state
             if (!$order->getPayin7OrderAccepted()) {
                 $order->setPayin7OrderAccepted(true);
                 $order->savePayin7Data();
             }
             if ($is_verified && $is_paid) {
                 /** @var OrderCore $orderm */
                 /** @noinspection PhpUndefinedClassInspection */
                 $orderm = new Order($order->getOrderId());
                 $state = $orderm->current_state;
                 if ($state == $this->module->getConfigIdOrderStatePending()) {
                     // temporarily disable updating history back to Payin7
                     $this->module->setHistoryUpdateEnabled(false);
                     $orderm->setCurrentState($this->module->getConfigIdOrderStateAccepted());
                     // reenable history
                     $this->module->setHistoryUpdateEnabled(true);
                     $message = 'Local order state set to (2): ' . $this->module->getConfigIdOrderStateAccepted();
                 }
             } else {
                 $message = 'Order not verified / paid';
                 $ret = false;
             }
             break;
     }
     return $ret;
 }