1、接收支付宝异步通知参数
这里以 thinkphp5 为例
$params = $this->request->post();
2、验证签名是否正确
// 如果支付成功
if (!empty($params) && $params['trade_status'] == 'TRADE_SUCCESS') {
// 验证签名
$aop = new AopClient();
$aop->alipayrsaPublicKey = ''; // 你的支付宝公钥
// 此处反转义fund_bill_list参数中的字符,否则验签不通过
$params['fund_bill_list'] = htmlspecialchars_decode($params['fund_bill_list']);
$checkSign = $aop->rsaCheckV1($params, null, 'RSA2');
if ($checkSign) {
// 验证通过
//……
echo 'success'; // 必需返回且只能返回success
}
}