下载最新的支付宝demo https://docs.open.alipay.com/203/105910
1. 手机版支付接口 目录
控制器调用支付接口
Vendor('alipay.wappay.service.AlipayTradeService');
Vendor('alipay.wappay.buildermodel.AlipayTradeWapPayContentBuilder');
// //商户订单号,商户网站订单系统中唯一订单号,必填
// //$out_trade_no = $_POST['WIDout_trade_no'];
// $out_trade_no = '27201'.date('YmdHis',time());
// $total_amount=0.01;
// //商品描述,可空
// $body = $_POST['WIDbody'];
//超时时间
$timeout_express="1m";
$payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
$config=cons();
$body=$out_trade_no=$tradeno;
$subject='账号充值';
$out_trade_no=$out_trade_no=$tradeno;
$total_amount=0.01;
$payRequestBuilder->setBody($body);
$payRequestBuilder->setSubject($subject);
$payRequestBuilder->setOutTradeNo($out_trade_no);
$payRequestBuilder->setTotalAmount($total_amount);
$payRequestBuilder->setTimeExpress($timeout_express);
$payResponse = new \AlipayTradeService($config);
$result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);
return ;
2.电脑版支付接口demo
demo 目录
电脑版的主要调用的是pagepay文件方法
控制器 这样加载
Vendor('alipay.pagepay.service.AlipayTradeService');
Vendor('alipay.pagepay.buildermodel.AlipayTradePagePayContentBuilder');
// //商户订单号,商户网站订单系统中唯一订单号,必填
// //$out_trade_no = $_POST['WIDout_trade_no'];
// $out_trade_no = '27201'.date('YmdHis',time());
// $total_amount=0.01;
// //商品描述,可空
// $body = $_POST['WIDbody'];
//超时时间
// $timeout_express="1m";
$payRequestBuilder = new \AlipayTradePagePayContentBuilder();
$config=cons();
$body=$out_trade_no=$tradeno;
$subject='账号充值';
$out_trade_no=$out_trade_no=$tradeno;
$total_amount=0.01;
$payRequestBuilder->setBody($body);
$payRequestBuilder->setSubject($subject);
$payRequestBuilder->setOutTradeNo($out_trade_no);
$payRequestBuilder->setTotalAmount($total_amount);
// $payRequestBuilder->setTimeExpress($timeout_express);
$payResponse = new \AlipayTradeService($config);
$result=$payResponse->pagePay($payRequestBuilder,$config['return_url'],$config['notify_url']);
return ;
和手机版 很相似的, 然后配置项在 common function.php 添加 这个方法
function cons(){
}//填写配置