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
}
}