mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	payment: support epay
This commit is contained in:
		
							
								
								
									
										69
									
								
								app/Payments/EPay.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								app/Payments/EPay.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace App\Payments; | ||||||
|  |  | ||||||
|  | class EPay { | ||||||
|  |     public function __construct($config) | ||||||
|  |     { | ||||||
|  |         $this->config = $config; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function form() | ||||||
|  |     { | ||||||
|  |         return [ | ||||||
|  |             'url' => [ | ||||||
|  |                 'label' => 'URL', | ||||||
|  |                 'description' => '', | ||||||
|  |                 'type' => 'input', | ||||||
|  |             ], | ||||||
|  |             'pid' => [ | ||||||
|  |                 'label' => 'PID', | ||||||
|  |                 'description' => '', | ||||||
|  |                 'type' => 'input', | ||||||
|  |             ], | ||||||
|  |             'key' => [ | ||||||
|  |                 'label' => 'KEY', | ||||||
|  |                 'description' => '', | ||||||
|  |                 'type' => 'input', | ||||||
|  |             ] | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function pay($order) | ||||||
|  |     { | ||||||
|  |         $params = [ | ||||||
|  |             'money' => $order['total_amount'] / 100, | ||||||
|  |             'name' => $order['trade_no'], | ||||||
|  |             'notify_url' => $order['notify_url'], | ||||||
|  |             'return_url' => $order['return_url'], | ||||||
|  |             'out_trade_no' => $order['trade_no'], | ||||||
|  |             'pid' => $this->config['pid'] | ||||||
|  |         ]; | ||||||
|  |         ksort($params); | ||||||
|  |         reset($params); | ||||||
|  |         $str = stripslashes(urldecode(http_build_query($params))) . $this->config['key']; | ||||||
|  |         $params['sign'] = md5($str); | ||||||
|  |         $params['sign_type'] = 'MD5'; | ||||||
|  |         return [ | ||||||
|  |             'type' => 1, // 0:qrcode 1:url | ||||||
|  |             'data' => $this->config['url'] . '/submit.php?' . http_build_query($params) | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function notify($params) | ||||||
|  |     { | ||||||
|  |         $sign = $params['sign']; | ||||||
|  |         unset($params['sign']); | ||||||
|  |         unset($params['sign_type']); | ||||||
|  |         ksort($params); | ||||||
|  |         reset($params); | ||||||
|  |         $str = stripslashes(urldecode(http_build_query($params))) . $this->config['key']; | ||||||
|  |         if ($sign !== md5($str)) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return [ | ||||||
|  |             'trade_no' => $params['out_trade_no'], | ||||||
|  |             'callback_no' => $params['trade_no'] | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user