1.所有用户的东西:
1.1下载支付宝官方网站的上的dome
1.2 申请appid
1.3 拿到应用公钥 应用私钥 以及支付宝公钥
2 .支付app支付
use app\common\library\aop\AopClient;
use app\common\library\aop\request\AlipayTradeAppPayRequest;
//支付宝支付
$aop = new AopClient();
$aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$aop->appId = '2021003139696117'; //正式
$aop->method = 'alipay.trade.app.pay';
$aop->charset = 'utf-8';
$aop->signType = 'RSA2';
//公药
$aop->alipayrsaPublicKey = '您的应用公钥';
//私钥
$aop->rsaPrivateKey = '您的应用私钥';
$biz_content = json_encode([
'out_trade_no' => 商户id订单的id,
'product_code' => 'FAST_INSTANT_TRADE_PAY',
'total_amount' => 价格元,
'subject' => '描述',
'timeout_express' => '时间',
]);
$payRequest = new AlipayTradeAppPayRequest();
$payRequest->setNotifyUrl('http://jiuzhihuijia.029xa.cn/index.php/api/callback/tancan');
$payRequest->setBizContent($biz_content);
$response = $aop->sdkExecute($payRequest);
return $this->renderSuccess([
'payType' => 'APP', // 支付方式
'payment' => $response, //支付宝支付参数
]);
3.回调
use app\common\library\aop\AopClient;
$aop = new AopClient;
$aop->alipayrsaPublicKey = '应用公钥';
$flag = $aop->rsaCheckV1($_POST, NULL, "RSA2");
if(!$flag){
//验签失败
echo "fail";
}else{
//你的支付宝公钥
echo "success";
}