私が支払いのための新しいモジュールを持っているとき、私はPrestaShop:bankwireが提供する最も簡単なものに頼っています。
内側に3つのフックがあります。
HookPayment:
public function hookPayment($params)
{
if (!$this->active)
return;
if (!$this->checkCurrency($params['cart']))
return;
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_bw' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment.tpl');
}
hookDisplayPaymentEU:
public function hookDisplayPaymentEU($params)
{
if (!$this->active)
return;
if (!$this->checkCurrency($params['cart']))
return;
$payment_options = array(
'cta_text' => $this->l('Pay by Bank Wire'),
'logo' => Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/bankwire.jpg'),
'action' => $this->context->link->getModuleLink($this->name, 'validation', array(), true)
);
return $payment_options;
}
hookPaymentReturn:
public function hookPaymentReturn($params)
{
if (!$this->active)
return;
$state = $params['objOrder']->getCurrentState();
if (in_array($state, array(Configuration::get('PS_OS_BANKWIRE'), Configuration::get('PS_OS_OUTOFSTOCK'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'))))
{
$this->smarty->assign(array(
'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false),
'bankwireDetails' => Tools::nl2br($this->details),
'bankwireAddress' => Tools::nl2br($this->address),
'bankwireOwner' => $this->owner,
'status' => 'ok',
'id_order' => $params['objOrder']->id
));
if (isset($params['objOrder']->reference) && !empty($params['objOrder']->reference))
$this->smarty->assign('reference', $params['objOrder']->reference);
}
else
$this->smarty->assign('status', 'failed');
return $this->display(__FILE__, 'payment_return.tpl');
}