https://opendocs.alipay.com/open/02np93
// Client
public function createAopClient()
{
$aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'APPID';
$aop->rsaPrivateKey = '私钥';
$aop->alipayrsaPublicKey = '公钥';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'UTF-8';
$aop->format = 'json';
return $aop;
}
// 支付
public function alipayTradeWapPayRequest(){
$aop = $this->createAopClient();
$request = new \AlipayTradeWapPayRequest();
$info = [
'body' => 'xxx',
'subject' => '标题',
// 商户网站唯一订单号,自定义的订单号
'out_trade_no' => time().rand(1111,9999),
'total_amount' => 1
];
$info = json_encode($info, JSON_UNESCAPED_UNICODE);
$request->setNotifyUrl('异步通知的URL');
$request->setReturnUrl('同步返回URL');
$request->setBizContent($info);
//这里和普通的接口调用不同,使用的是sdkExecute
$result = $aop->pageExecute($request);
}
// 回调验签
public function checkSign($param = [])
{
$app = new \AopClient();
$app->alipayrsaPublicKey = '公钥';
$res = $app->rsaCheckV1($param, '私钥', 'RSA2');
return $res;
}