支付宝、盛付通支付接口简单案列
这篇文章简单讲述了支付宝、盛付通支付接口简单案列,通俗易懂,简单明了、=。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<?php class test { private $key='111'; /*验证*/ public function verify() { $prepare_data['a']='aaa'; $prepare_data['b']='bbb'; $prepare_data['c']='ccc'; $prepare_data['d']='ddd'; $prepare_data['e']='eee'; $prepare_data['f']='fff'; $prepare_data['g']='ggg'; $prepare_data['h']='hhh'; $prepare_data['i']='iii'; $prepare_data['k']=''; foreach($prepare_data as $value){ if(!empty($value)) $origin.=$value; } $prepare_data['SignMsg']=strtoupper(md5($origin.$this->key)); return $prepare_data; } /*相应*/ public function receive() { if($this->returnSign()){ /*支付成功*/ $return_data['order_id'] = $_POST['OrderNo']; $return_data['payment_id'] = $_POST['TransNo']; $return_data['price'] = $_POST['TransAmount']; $return_data['order_status'] = 0; return $return_data; echo 'OK'; }else{ echo 'Error'; error_log(date('m-d H:i:s',SYS_TIME).'| GET: illegality notice : flase |'."\r\n", 3, CACHE_PATH.'pay_error_sanda.php'); showmessage(L('illegal_sign')); return false; } } /*响应数据验证*/ private function returnSign(){ $params=array( 'aaa'=>'', 'bbb'=>'', 'ccc'=>'', 'ddd'=>'', 'eee'=>'', 'fff'=>'', 'ggg'=>'', 'hhh'=>'', 'iii'=>'', 'SignType'=>'MD5', ); foreach($_POST as $key=>$value){ if(isset($params[$key])){ $params[$key]=$value; } } $TransStatus=(int)$_POST['TransStatus']; $origin=''; foreach($params as $key=>$value){ if(!empty($value)) $origin.=$value; } $SignMsg=strtoupper(md5($origin.$this->key)); if($SignMsg==$_POST['SignMsg'] and $TransStatus==1){ return true; }else{ return false; } } } $object=new test(); var_dump($object->verify()); ?> |
- 微软Xbox One今日上市 零售商称对销量很期待
- 诸葛亮机关算尽,为何最终斗不过司马懿?