Last active
August 1, 2019 07:28
-
-
Save JellyBool/406adefb2707a0e0780b to your computer and use it in GitHub Desktop.
alipay payment gateway verify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function isFromAlipay($notifyId) | |
{ | |
$url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&partner=' . trim(env('ALIPAY_PID')) . '¬ify_id=' . $notifyId; | |
$response = $this->httpGet($url); | |
return (bool) preg_match("/true$/i",$response); | |
} | |
protected function httpGet($url) | |
{ | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头 | |
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果 | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL证书认证 | |
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//严格认证 | |
curl_setopt($curl, CURLOPT_CAINFO, public_path() . '/cacert.pem');//证书地址 | |
$response = curl_exec($curl); | |
curl_close($curl); | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment