本文实例为大家分享了php支付宝APP支付的具体代码,供大家参考,具体内容如下
支付宝网页支付
1.支付宝开放平台添加应用,获得appid,并签约。
2.在支付宝开放品台设置如下:
3.配置支付宝的应用公钥。(根据支付宝的文档)
4.在开放平台下载官方sdk demo。
5.代码:
//支付宝 include_once VENDOR_PATH . 'Alipay/aop/AopClient.php'; include_once VENDOR_PATH . 'Alipay/aop/request/AlipayTradeAppPayRequest.php'; $notify_url='https:///gateway.do"; $aop->appId = $config['appid']; $aop->rsaPrivateKey = $config['rsaPrivateKey']; $aop->format = "json"; $aop->charset = "UTF-8"; $aop->signType = "RSA2"; $aop->method = $config['method']; $aop->apiVersion = '1.0'; $aop->alipayrsaPublicKey=$config['alipayrsaPublicKey']; //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.query $request = new \AlipayTradeQueryRequest(); $bizcontent = json_encode([ 'out_trade_no'=>$order_sn, 'trade_no'=>'' ]); $request->setBizContent($bizcontent); $response = $aop->execute($request); $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; $resultCode = $response->$responseNode->code; if(!empty($resultCode)&&$resultCode == 10000){ $this->arr['code']=0; $this->arr['msg']='success'; echo json_encode($this->arr);exit; } else { $this->arr['code']=100001; $this->arr['msg']='未查询到订单信息'; echo json_encode($this->arr);exit; }以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。