Yii framework alipay
担保交易扩展, (*1)
支付宝官方文档改编。。支持手机wap 及pc支付, (*2)
安装 composer require life2016/yii2-alipay "*", (*3)
配置 设置common/config/params.php, (*4)
return [ 'adminEmail' => 'xxxxx@qq.com',, (*5)
'supportEmail' => 'xxxxxxx@qq.com', 'user.passwordResetTokenExpire' => 3600, 'showUrl'=>'http://www.sasr.cn/index.php', 'notifyUrl' => 'http://www.sasr.cn/index.php/ali-return/notify', 'returnUrl' => 'http://www.sasr.cn/index.php/ali-return/returned', 'aliPartner' => 'xxxxxxxxxxxxx', 'aliSellerEmail' => 'xxxxxx@126.com', 'aliKey'=> 'xxxxxxxx'
];, (*6)
使用, (*7)
use leyestd\alipay\Alipay;, (*8)
use leyestd\alipay\lib\AlipaySubmit;, (*9)
//参数为支付宝所需,详细请看构造方法, (*10)
$alipay=new Alipay($order->orderNumber, ltrim($productSkus),$cost,$order->notes,$show_url,$recipient->name,$recipient->address,$recipient->postcode,$recipient->phone,$recipient->mobile);, (*11)
$html_text = (new AlipaySubmit($alipay->alipay_config))->buildRequestForm($alipay->parameter, "get", "确认");, (*12)
echo $html_text;, (*13)
支付宝支付后返回, (*14)
$alipayNotify = new AlipayNotify((new Aliconfig)->getAliconfig());, (*15)
$verify_result = $alipayNotify->verifyReturn();, (*16)
以下为支付宝支付后通知, (*17)
$alipayNotify = new AlipayNotify((new Aliconfig)->getAliconfig());, (*18)
$verify_result = $alipayNotify->verifyNotify();, (*19)
日志, (*20)
默认在frontend/runtime/logs/alilog.txt 需要写入权限, (*21)
也可自己修改AlipayCore下的logResult方法到指定位置, (*22)