Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PAYJS收银台模式DEMOO
<?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
You can’t perform that action at this time.