{ "alipay_trade_precreate_response":{ "code":"10000", "msg":"Success", "out_trade_no":"qrpay20160826053813582", "qr_code":"https://qr.alipay.com/bax00885xbhszseo9l7p404d" }, "sign":"VfNTGo2WMZ+2CE1L05lNYWtFn4inHXO/tUaBZIBHN4fPlXnCvyc9IhS8S7wa3FYw23G30luEPEHkZWobnfpUjILonmExZVElHv3ylINz+Q2mQ5M8Sb/d61YPvf4Bgy1OvlrT4D3H/i3judmzEDBrOyFN9kB9vSkKaYC+b6L41Zw=" }
其中的https://qr.alipay.com/bax00885xbhszseo9l7p404d 就是二维码链接地址,使用接口将其成二维码后。
当支付宝用户扫码的时候,接口通知将收到如下数据
{ "notify_id":"4c2c04c3cc50e978d44212febe7c3f0lse", "seller_email":"pay***@fangbei.org", "notify_type":"trade_status_sync", "sign":"R0iRdYmSQ0+zuSUGLzkutHcR40hoOp+CcKojVBCMa1uji3rqQFe5XeHoJB1nMBCApE3zXPKhXMdLis109ngPbGy+NUEBR7YZjYuR/hXq3WXeYfZ8aiWLvloZHrF7dQWxDho/VHYexaLeqvRi/03m0HxrwhZKUOu1eS9wMgZOlqQ=", "trade_no":"2016082621001004750241229810", "buyer_id":"2088002364008751", "app_id":"2016061501500000", "gmt_create":"2016-08-26 18:20:37", "out_trade_no":"qrpay20160826062009757", "seller_id":"2088421202724253", "notify_time":"2016-08-26 18:20:37", "subject":"方倍工作室-支付宝-当面付-扫码支付", "trade_status":"WAIT_BUYER_PAY", "open_id":"20880044751374809757987911112575", "total_amount":"0.01", "sign_type":"RSA", "buyer_logon_id":"118***@qq.com" }
当用户输入密码付款成功之后,将收到如下数据
{ "fund_bill_list":"[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]", "subject":"方倍工作室-支付宝-当面付-扫码支付", "trade_no":"2016082621001004750241229810", "gmt_create":"2016-08-26 18:20:37", "notify_type":"trade_status_sync", "total_amount":"0.01", "out_trade_no":"qrpay20160826062009757", "invoice_amount":"0.01", "open_id":"20880044751374809757987911112575", "seller_id":"2088421202724253", "notify_time":"2016-08-26 18:20:50", "trade_status":"TRADE_SUCCESS", "gmt_payment":"2016-08-26 18:20:50", "seller_email":"pay***@fangbei.org", "receipt_amount":"0.01", "buyer_id":"2088002364008751", "app_id":"2016061501500000", "notify_id":"56f97611ee609f46384b188b409e75else", "buyer_logon_id":"118***@qq.com", "sign_type":"RSA", "buyer_pay_amount":"0.01", "sign":"nf/KJryACk0utqlNrnuYMiSnYw6HsxqpJPk2O5MhCZ+wZUVQbrD3sq5POO3GU7LSRoSiUUIO4JEYEL12Ek2+w3lTcLS9WEi60sYowPOcJEYGmVfNZbVR6+k7yO5au2WIkM3MKsxm2XxIB9xPMmRDACGhvqZ2BXUAQujkPk1FT0s=", "point_amount":"0.00" }
3. 订单查询
订单查询的参数配置如下
////获取商户订单号 $out_trade_no = trim($_POST['out_trade_no']); //第三方应用授权令牌,商户授权系统商开发模式下使用 $appAuthToken = "";//根据真实值填写 //构造查询业务请求参数对象 $queryContentBuilder = new AlipayTradeQueryContentBuilder(); $queryContentBuilder->setOutTradeNo($out_trade_no); $queryContentBuilder->setAppAuthToken($appAuthToken); //初始化类对象,调用queryTradeResult方法获取查询应答 $queryResponse = new AlipayTradeService($config); $queryResult = $queryResponse->queryTradeResult($queryContentBuilder); //根据查询返回结果状态进行业务处理 switch ($queryResult->getTradeStatus()){ case "SUCCESS": echo "支付宝查询交易成功:"."<br>--------------------------<br>"; print_r($queryResult->getResponse()); break; case "FAILED": echo "支付宝查询交易失败或者交易已关闭!!!"."<br>--------------------------<br>"; if(!empty($queryResult->getResponse())){ print_r($queryResult->getResponse()); } break; case "UNKNOWN": echo "系统异常,订单状态未知!!!"."<br>--------------------------<br>"; if(!empty($queryResult->getResponse())){ print_r($queryResult->getResponse()); } break; default: echo "不支持的查询状态,交易返回异常!!!"; break; }
最终提交的url如下
发送的json数据如下:
{ "out_trade_no":"qrpay20160826053813582" }
接收到的数据如下