1
當客戶返回到以下URL(示例)時;我的訂單完整退貨方式是否正確?
http://prestashop.dev/index.php?action=completed&controller=callback&fc=module&hmac={valid-hmac}&merchant_order_id=14&module=chippin
成功付款後,它會調用這個FrontController子類;
class ChippinCallbackModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$chippin = new Chippin();
$payment_response = new PaymentResponse();
$payment_response->getPostData();
// if a valid response from gateway
if(ChippinValidator::isValidHmac($payment_response)) {
// "action" is passed as a param in the URL. don't worry, the Hmac can tell if it's valid or not.
if ($payment_response->getAction() === "completed") {
// payment_response->getMerchantOrderId() will just return the id_order from the orders table
$order_id = Order::getOrderByCartId((int) ($payment_response->getMerchantOrderId()));
$order = new Order($order_id);
// this will update the order status for the benefit of the merchant.
$order->setCurrentState(Configuration::get('CP_OS_PAYMENT_COMPLETED'));
// assign variables to smarty (copied this from another gateway, don't really understand smarty)
$this->context->smarty->assign(
array(
'order' => $order->reference,
)
);
// display this template
$this->setTemplate('confirmation.tpl');
我是Prestashop的新手。我只是不確定這是否在技術上完成。 confirmation.tlp
視圖會顯示order->reference
,訂單狀態更新爲「已完成」,但這是我需要的嗎?
有沒有其他的考慮?我有機會在此時調用hookDisplayPaymentReturn,但爲什麼我應該?
我似乎有一個非常標準的返回頁面。這夠了嗎;
更新 - 我只需要調用一個鉤子一樣的東西;
public function displayPaymentReturn()
{
$params = $this->displayHook();
if ($params && is_array($params)) {
return Hook::exec('displayPaymentReturn', $params, (int) $this->module->id);
}
return false;
}
什麼,所以不是直接調用了'confirmation.tpl'頁面,我應該做的鉤?或者只是有一個空鉤子方法? - 查看我的更新 – mikelovelyuk
您正在使用顯示確認模板的快捷方式。實際上,您應該重定向到訂單確認控制器,該控制器將爲您完成該過程。在你的模塊中,你可以鉤上'displayPaymentReturn'或'displayOrderConfirmation'。查看我的編輯 –
查看'bankwire'模塊(這是默認的Prestashop模塊)。這是一個非常簡單的理解模塊。 –