用支付宝的sdk
服务端SDK
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '2018111962265438';
$aop->rsaPrivateKey = 'thZJL2VT0PlgHCgYEAzwp';//开发者的私钥
$aop->alipayrsaPublicKey='ZvpB';//支付宝的公钥
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='UTF-8';
$aop->format='json';
//支付必要参数
$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 '成功'
}
使用支付宝提供的密钥生成器,这个再创建公钥的时候有提供下载
密钥生成器下载地址
这个开发者的私钥
这个是支付宝的公钥