How docking personal collection payment interface (scan code to pay)

To achieve personal collection is a very troublesome thing, you can paybob registered personal collection interfaces, help signing personal Alipay, micro-channel payment interface (do not need a business license), can be opened a few minutes after the subscription, acquisition and merchant number communication key, and then began docking, this chapter mainly talk about the scan code to pay

  • Scan code of the payment request step of:
  1. Construction Request parameter
  2. POST parameters to request address
  3. Shows two-dimensional code based on the contents of return
  4. Users receive asynchronous notification of successful payment
  • 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://paybob.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;
    }
  • The top business and communication key number into their own. The final print out the scan code to the interface returns the result.
  • Results scan code returned by the interface, wherein the two-dimensional code is code_url content may be generated by the two-dimensional code into the class two-dimensional code. Or interface returned qrcode parameter that is two-dimensional code image address to the two-dimensional code is 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, after the payment is complete, the server will receive asynchronous notification of successful payment. Self-triggering further processing and business logic.
  • Finally, the signature generation and share with you the following general procedure :( detail, for example )
  1. Provided all data sent or received as a set of M, the set of parameters for non-empty parameter values ​​in M ​​by parameter name ASCII codes in ascending order (lexicographic), using the format of the URL value pairs (i.e., key1 = value1 & key2 = value2 ...) spliced ​​into a string stringA.
  2. On the final splice stringA obtained stringSignTemp key & key = string, and stringSignTemp MD5 calculation performed, then the resulting character string is converted to uppercase all give sign value

Future will continue to share the cashier mode (click on the link to enter the proper way to review a cloud), mode of payment jsapi hope that we can provide more information,

Guess you like

Origin www.cnblogs.com/paybob1/p/11246016.html