Last active
April 8, 2019 04:09
-
-
Save payjscn/a05b96bf20ecb46dc32bc76c71f09419 to your computer and use it in GitHub Desktop.
PAYJS收银台模式DEMOO
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 | |
$mchid = '**************'; // PAYJS 商户号 | |
$key = '**************'; // 通信密钥 | |
// 构造订单参数 | |
$data = [ | |
'mchid' => $mchid, | |
'body' => '我是一个测试订单标题', | |
'total_fee' => 1, | |
'out_trade_no' => 'payjs_jspay_demo_' . time(), | |
]; | |
// 添加数据签名 | |
$data['sign'] = sign($data, $key); | |
// 浏览器跳转到收银台 | |
$url = 'https://payjs.cn/api/cashier?' . http_build_query($data); | |
header('Location: ' . $url); | |
// 获取签名 | |
function sign($data, $key) | |
{ | |
array_filter($data); | |
ksort($data); | |
return strtoupper(md5(urldecode(http_build_query($data) . '&key=' . $key))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment