prestashop支付流程

首先需要安装支付模块,以我的支付模块ingenico为例。
1,根目录文件ingenico.php (model文件)需要引入支付接口文件,需要引入prestashop支付模块文件
class Ingenico extends PaymentModule
{
}
2,安装的时候会执行install函数,install里挂载钩子
public function install()
{
}
,3,执行钩子函数
public function hookPaymentOptions(KaTeX parse error: Expected '}', got 'EOF' at end of input: …{ if (!this->active) {
return;
}
if (! t h i s > c h e c k C u r r e n c y ( this->checkCurrency( params[‘cart’])) {
return;
}
$payment_options = [
$this->getIngenicoPaymentOption(),
];
return $payment_options;
}
,4, 执行需要调用的controller文件(modules/ingenico/controllers/front/iframe.php):
public function getIngenicoPaymentOption()
{
$engenicoPaymentOption = new PaymentOption();
e n g e n i c o P a y m e n t O p t i o n > s e t C a l l T o A c t i o n T e x t ( engenicoPaymentOption->setCallToActionText( this->l(‘Pay whith Ingenico’))
->setAction( t h i s > c o n t e x t > l i n k > g e t M o d u l e L i n k ( this->context->link->getModuleLink( this->name, ‘iframe’, array(), true))
->setAdditionalInformation($this->context->smarty->fetch(‘module:Ingenico/views/templates/front/ingenico.tpl’))
->setLogo(Media::getMediaPath(PS_MODULE_DIR . $this->name . ‘/payment.jpg’));
return $engenicoPaymentOption;
}
,5, controller文件调用支付接口生成的url返回到model文件ingenico.php,(controller文件iframe.php需要引入接口文件)
include_once PS_MODULE_DIR . ‘ingenico/vendor/autoload.php’;
include_once PS_MODULE_DIR . ‘ingenico/ingenico.php’;
use Ingenico\Connect\Sdk\Examples\HostedCheckoutTest;

 	$ingenico = new Ingenico();
    $payment_html = $ingenico->execPayment($this->context->cart, 'CreditCard', $con_string);
    $payment_html .= '<script>document.payForm.submit(); </script>';

,6, model文件 ingenico.php 获取返回的url和其他信息向支付页面发出请求
public function execPayment($cart, $APMType, $con_string){
$payment_html = ’



';
return $payment_html;
}
7,执行回调页面
returnUrl = “http://www.test.com/module/ingenico/test”;
8.回调页面返回的结果传递给model(ingenico.php)
将返回的订单状态插入到数据表

猜你喜欢

转载自blog.csdn.net/qq_30439399/article/details/88661719