用支付寶的sdk
服務(wù)端SDK
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '2018111962265438';
$aop->rsaPrivateKey = 'thZJL2VT0PlgHCgYEAzwp';//開(kāi)發(fā)者的私鑰
$aop->alipayrsaPublicKey='ZvpB';//支付寶的公鑰
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='UTF-8';
$aop->format='json';
//支付必要參數(shù)
$request = new AlipayTradeCreateRequest ();
$content = array();
$content['out_trade_no'] = $order;
$content['total_amount'] = sprintf('%.2f',$allmoney);
$content['subject'] = '外賣小吃';
$content['buyer_id'] = '2088802486734682';
$content=json_encode($content);
$request->setBizContent($content);
$result = $aop->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo '成功'
}
使用支付寶提供的密鑰生成器最岗,這個(gè)再創(chuàng)建公鑰的時(shí)候有提供下載
密鑰生成器下載地址
這個(gè)開(kāi)發(fā)者的私鑰
這個(gè)是支付寶的公鑰