It is very troublesome to realize personal payment. You can register personal payment interface through PayBob to help sign personal Alipay and wechat payment interface (business license is not required), which can be opened in a few minutes. After applying for opening, you can obtain the merchant number and communication key, and then start docking

  • Scan the payment request steps:

  1. Build request parameters
  2. POST parameter to request address
  3. Display the QR code according to the returned content
  4. The user receives an asynchronous notification after the payment is successful
  • Sweep yards docking

    The PHP code looks like this:


      
     $order = [
        'mchid'= >'xxxxxxxxxxx'.'body'= >'test'.// Order title
        'out_trade_no' => time(),       / / order number
        'total_fee'= >120.// Amount, unit: minute
    ];
    $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;
    }
Copy the code
  • Replace the merchant number and communication key with your own. Finally, the scan code interface can be printed to return the result.
  • In the result returned by the scanning interface, code_URL is the content of the TWO-DIMENSIONAL code, which can be converted into the two-dimensional code by the class generated by the two-dimensional code. Or the qrcode parameter returned by the interface is the picture address of the two-dimensional code, and the two-dimensional code is displayed to the user. The user can scan the qrcode for payment through the scanning function of mobile phone wechat.
  • Note that asynchronous notification is not demonstrated in the demo code above. If asynchronous notification is required, you can add a notify_URL parameter, so that the server receives an asynchronous notification of successful payment when the payment is complete. It can further trigger and process business logic by itself.
  • Finally, I would like to share with you the general steps of signature generation as follows :(detailed examples)
  1. Let all the data sent or received be set M, and sort the parameters of non-empty parameter values in set M from the smallest to the largest ASCII number of parameter names (lexicographical order), using the FORMAT of URL key-value pairs (key1=value1&key2=value2…) Concatenated to the string stringA.
  2. At the end of the concatenation of stringA, &key= key is used to obtain the stringSignTemp string. MD5 operation is performed on stringSignTemp, and all characters of the string are converted to uppercase to obtain the value of sign

In the future, I will share the cashier mode and JSAPI mode with you successively (you can click to enter the Youdao Cloud link to check first). I hope to provide you with more references.