/** * This method is called when the customer goes back to shop, after he made a payment. * The customer will redirected either to the order confirmation page or to an error page * @return mixed */ public function postProcess() { require_once dirname(__FILE__) . '/../../api/loader.php'; $alipay = new Alipay(); $payment_response = new PaymentResponse(); $payment_response->getPostData(); if ($payment_response->getTradeStatus() == 'TRADE_FINISHED') { $payment_response->setIdModule($this->module->id); if (!$payment_response->processResponse()) { $errors = $payment_response->getErrors(); if ($errors) { foreach ($errors as $error) { $this->errors[] = $error; } return $this->setTemplate('error.tpl'); } } if ($payment_response->getIdOrder()) { $params = array('id_cart' => $payment_response->getIdCart(), 'id_module' => $payment_response->getIdModule(), 'id_order' => $payment_response->getIdOrder(), 'key' => $payment_response->getSecureKey()); $s = $this->context->link->getModuleLink('alipay', 'confirmation', $params); Tools::redirect($s); } else { $this->context->smarty->assign($payment_response->getTplVars()); return $this->setTemplate('check_order.tpl'); } } $this->errors[] = $alipay->l('An error occured. Please contact the merchant to have more informations'); return $this->setTemplate('error.tpl'); }