Among the many personal products in the payment interface, looking for a stable and reliable product is more difficult, but fortunately encountered payjs, higher feeling forced the grid, very satisfying their taste. Recommend everyone to use. Below is the process of my butt payjs of some of the experience and skills to others.
First, the merchant application No.
Open payjs official website to subscribe to get the merchant number and communication key
Second, the scan code docking
php code is as follows:
<?php
$order = [
'mchid' => 'xxxxxxxxxxx',
'body' => 'test', // 订单标题
'out_trade_no' => time(), // 订单号
'total_fee' => 120, // 金额,单位:分
];
$order['sign'] = sign($order);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://payjs.cn/api/native');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $order);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$rst = curl_exec($ch);
curl_close($ch);
print_r($rst);
function sign(array $attributes) {
ksort($attributes);
$sign = strtoupper(md5(urldecode(http_build_query($attributes)) . '&key=' . 'xxxxxxxxxxxx'));
return $sign;
}
Note that the above number of businesses and communicate key into their own. The final print out the scan code to the interface returns the result.-
Results returned by the interface scan code, which
code_url
is the content of the two-dimensional code, the two-dimensional code may be generated by the class into two-dimensional code. Or interface returnedqrcode
parameter that is two-dimensional code image address -
The two-dimensional code presented to the user, the user can be swept away by a sweep function mobile micro letter, a scan code to pay.
-
It should be noted that the above demo code does not demonstrate asynchronous notification. If you need asynchronous notification, you can add a
notify_url
parameter, then after the payment is complete, the server will receive asynchronous notification of successful payment. Self-triggering further processing and business logic. - payjs official website