How docking payjs personal micro-channel scan code payment interface

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:

  1. <?php
  2. $order = [
  3. 'mchid' => 'xxxxxxxxxxx',
  4. 'body' => 'test', // 订单标题
  5. 'out_trade_no' => time(), // 订单号
  6. 'total_fee' => 120, // 金额,单位:分
  7. ];
  8. $order['sign'] = sign($order);
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_URL, 'https://payjs.cn/api/native');
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($ch, CURLOPT_POST, 1);
  13. curl_setopt($ch, CURLOPT_POSTFIELDS, $order);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  16. $rst = curl_exec($ch);
  17. curl_close($ch);
  18. print_r($rst);
  19. function sign(array $attributes) {
  20. ksort($attributes);
  21. $sign = strtoupper(md5(urldecode(http_build_query($attributes)) . '&key=' . 'xxxxxxxxxxxx'));
  22. return $sign;
  23. }
  • 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 returned  qrcode 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

Guess you like

Origin www.cnblogs.com/paybob/p/11005016.html