//支付调用
public function alipay()
{
$money = $_REQUEST['money'];
//支付标题 内容
$attach = $_REQUEST['attach'];
$aop = new AopClient ();
$this->out_trade_no = substr(build_order_no().uniqid(),0,32);
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; //请求地址
$aop->appId = config('alipay_id'); //自己的支付宝APPID
$aop->rsaPrivateKey = config('private_key'); //私钥
$aop->apiVersion = '1.0';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->signType='RSA2';
//后台生成订单
$order_res = $this->OrderModel->addOrder($order_info);
$request = new AlipayTradeWapPayRequest();
$request->setNotifyUrl('');//异步回调地址
$request->setReturnUrl('');//同步回调地址
$request->setBizContent("{" .
" \"body\":\"".$attach."\"," .
" \"subject\":\"".$attach."\"," .
" \"out_trade_no\":\"".$this->out_trade_no."\"," .
" \"timeout_express\":\"90m\"," .
" \"total_amount\":".$money."," .
" \"product_code\":\"QUICK_WAP_WAY\"" .
" }");
$result = $aop->pageExecute ($request);
return $result;
}
/**
* 支付宝支付回调页面
* @param string $type [description]
* @return [type] [description]
*/
public function backHtmlAlipayUrl($type='alipay')
{
回调数据:
// "gmt_create": "2018-08-29 09:44:11",
// "charset": "utf-8",
// "seller_email": "",
// "subject": "",
// "sign": "",
// "body": "",
// "buyer_id": "",
// "invoice_amount": "0.01",
// "notify_id": "",
// "fund_bill_list": "[{\"amount\":\"0.01\",\"fundChannel\":\"ALIPAYACCOUNT\"}]",
// "notify_type": "trade_status_sync",
// "trade_status": "TRADE_SUCCESS",
// "receipt_amount": "0.01",
// "buyer_pay_amount": "0.01",
// "app_id": "",
// "sign_type": "RSA2",
// "seller_id": "",
// "gmt_payment": "2018-08-29 09:44:12",
// "notify_time": "2018-08-29 09:44:12",
// "version": "1.0",
// "out_trade_no": "",
// "total_amount": "0.01",
// "trade_no": "",
// "auth_app_id": "",
// "buyer_logon_id": "",
// "point_amount": "0.00"
// end 打印数据
$alipay_info = $_POST;
$info = 调用自己的其他方法完成逻辑处理
if ($info['status'] == 1) {
echo 'success'; //回调必须反的字段 否则支付宝会一直发起请求
}else{
echo 'fail';
}
}