$appCertPath = dirname(FILE)."./…/…/zhifubao/cert/appCertPublicKey_1222.crt";
$alipayCertPath = dirname(FILE)."./…/…/zhifubao/cert/alipayCertPublicKey_RSA2.crt";
$rootCertPath = dirname(FILE)."./…/…/zhifubao/cert/alipayRootCert.crt";
include_once dirname(FILE).’./…/…/zhifubao/AopCertClient.php’;
include_once dirname(FILE).’./…/…/zhifubao/request/AlipayTradeAppPayRequest.php’;
$aop = new \AopCertClient();
$aop->gatewayUrl = ‘https://openapi.alipay.com/gateway.do’;
$aop->appId = ‘youAPPID’;
$aop->rsaPrivateKey =‘应用私钥’ ;
$aop->alipayrsaPublicKey =
a
o
p
−
>
g
e
t
P
u
b
l
i
c
K
e
y
(
aop->getPublicKey(
aop−>getPublicKey(alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->isCheckAlipayPublicCert = false;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内
$aop->appCertSN = $aop->getCertSN($appCertPath);//调用getCertSN获取证书序列号
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
$request = new \AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数,这里只需要传入业务参数
$total_amount = 0.01;
d
a
t
a
=
[
′
b
o
d
y
′
=
>
′
智
链
卡
支
付
′
,
′
s
u
b
j
e
c
t
′
=
>
′
智
链
卡
A
P
P
支
付
′
,
′
o
u
t
t
r
a
d
e
n
o
′
=
>
data = [ 'body'=>'智链卡支付', 'subject'=>'智链卡APP支付', 'out_trade_no'=>
data=[′body′=>′智链卡支付′,′subject′=>′智链卡APP支付′,′outtradeno′=>out_trade_no,
‘timeout_express’=>‘30m’,
‘total_amount’=>$total_amount,
‘product_code’=>‘QUICK_MSECURITY_PAY’,
];
b
i
z
c
o
n
t
e
n
t
=
j
s
o
n
e
n
c
o
d
e
(
bizcontent = json_encode(
bizcontent=jsonencode(data);
$request->setNotifyUrl(‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/api.php’ . $notify_url);
r
e
q
u
e
s
t
−
>
s
e
t
B
i
z
C
o
n
t
e
n
t
(
request->setBizContent(
request−>setBizContent(bizcontent);
//这里和普通的接口调用不同,使用的是sdkExecute
$response =
a
o
p
−
>
s
d
k
E
x
e
c
u
t
e
(
aop->sdkExecute(
aop−>sdkExecute(request);
return $response;