Skip to content

Instantly share code, notes, and snippets.

@payjscn
Created July 3, 2019 10:16
Show Gist options
  • Save payjscn/c67a4169600436e593ac42de04e2c777 to your computer and use it in GitHub Desktop.
Save payjscn/c67a4169600436e593ac42de04e2c777 to your computer and use it in GitHub Desktop.
PAYJS 订单查询接口 PHP DEMO
<?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