Created
July 3, 2019 10:16
-
-
Save payjscn/c67a4169600436e593ac42de04e2c777 to your computer and use it in GitHub Desktop.
PAYJS 订单查询接口 PHP DEMO
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 | |
class Payjs | |
{ | |
private $url = 'https://payjs.cn/api/check'; | |
private $key = ''; // 填写通信密钥 | |
private $mchid = ''; // 特写商户号 | |
public function __construct($payjs_order_id=null) { | |
$this->payjs_order_id = $payjs_order_id; | |
} | |
public function check(){ | |
$data = array(); | |
$data['payjs_order_id'] = $this->payjs_order_id; | |
$data['sign'] = $this->sign($data); | |
return $this->post($data, $this->url); | |
} | |
public function post($data, $url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
$rst = curl_exec($ch); | |
curl_close($ch); | |
return $rst; | |
} | |
public function sign(array $attributes) { | |
ksort($attributes); | |
$sign = strtoupper(md5(urldecode(http_build_query($attributes)) . '&key=' . $this->key)); | |
return $sign; | |
} | |
} | |
$payjs_order_id = '2019***********'; // 订单号 | |
$payjs = new Payjs($payjs_order_id); | |
$rst = $payjs->check(); | |
print_r($rst); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment