123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- require_once("alipay_core.function.php");
- require_once("alipay_rsa.function.php");
- class AlipayNotify {
- function __construct($config){
- $this->config = $config;
- }
- function AlipayNotify($config) {
- $this->__construct($config);
- }
-
- function verifyNotify(){
- if(empty($_POST)) {
- return false;
- }
- else {
-
- $isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
-
- if ($isSign) {
- return true;
- } else {
- return false;
- }
- }
- }
-
-
- function verifyReturn(){
- if(empty($_GET)) {
- return false;
- }
- else {
-
- $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
-
- $responseTxt = 'false';
- if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (preg_match("/true$/i",$responseTxt) && $isSign) {
- return true;
- } else {
- return false;
- }
- }
- }
-
-
- function getSignVeryfy($para_temp, $sign) {
-
- $para_filter = paraFilter($para_temp);
-
-
- $para_sort = argSort($para_filter);
-
-
- $prestr = createLinkstring($para_sort);
-
- $isSgin = false;
- switch (strtoupper(trim($this->alipay_config['sign_type']))) {
- case "RSA" :
- $isSgin = rsaVerify($prestr, trim($this->alipay_config['alipay_public_key']), $sign);
- break;
- default :
- $isSgin = false;
- }
-
- return $isSgin;
- }
-
- function getResponse($notify_id) {
- $transport = strtolower(trim($this->alipay_config['transport']));
- $partner = trim($this->alipay_config['partner']);
- $veryfy_url = '';
- if($transport == 'https') {
- $veryfy_url = $this->https_verify_url;
- }
- else {
- $veryfy_url = $this->http_verify_url;
- }
- $veryfy_url = $veryfy_url."partner=" . $partner . "¬ify_id=" . $notify_id;
- $responseTxt = getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']);
-
- return $responseTxt;
- }
- }
- ?>
|