Fast docking payjq personal micro-channel payment interface (cash register mode)

Recent payment interface in the understanding of individuals, hoping to solve the problem I pay on micro letter. Find a lot of platform comparison again, feeling payjq more professional. At the same time support payments and micro-letters, because I Alipay has not opened (only need to have a certain flow to the opening), it highlights some docking micro letter cashier mode. Record it.

Cashier docking mode is very simple, there is an official development kit can be used directly, or develop their own relatively simple.

A personal approach through code implementation
  • Business communication key number and configuration
  $mchid = '**************'; // PAYJQ 商户号
  $key   = '**************'; // 通信密钥
  • Construction orders
  // 构造订单参数
  $data = [
      'mchid'        => $mchid,
      'body'         => '我是一个测试订单标题',
      'total_fee'    => 1,
      'out_trade_no' => 'payjq_jspay_demo_' . time(),
  ];
  • Signature Algorithm
  // 获取签名
  function sign($data, $key)
  {
      array_filter($data);
      ksort($data);
      return strtoupper(md5(urldecode(http_build_query($data) . '&key=' . $key)));
  }
  • Orders endorsement
  // 添加数据签名
  $data['sign'] = sign($data, $key);
  • Browser Jump
  // 浏览器跳转到收银台
  $url = 'https://payjq.cn/api/cashier?' . http_build_query($data);
  header('Location: ' . $url);
  • All steps have been completed. You can normally initiate payment

  • Need to remind that the last step in the browser jump action, need to launch a browser, you can not get back-end code and then launched
Processing Second, asynchronous notification
  // 构造订单参数
  $data = [
      'mchid'        => $mchid,
      'body'         => '我是一个测试订单标题',
      'total_fee'    => 1,
      'out_trade_no' => 'payjq_jspay_demo_' . time(),
      'notify_url'   => 'http://www.xxx.com/payjq/notify.php',
  ];

Thus, after the user pays finished, my server can receive the asynchronous notification. After testing, asynchronous notification of the arrival time is generally within 1 second they received, feel the delay. Just when I was in the front end of polling polls may three seconds relatively low frequency

The entire process is very simple, if there are questions you can ask questions at any time.

The next article will introduce paid jsapi mode, this use more perfect, suitable for the development of the ability of students to use

Guess you like

Origin blog.51cto.com/14393381/2429573