Home  >  Q&A  >  body text

How to connect to personal payment interface (scan QR code to pay)

Implementing personal collection is a very troublesome thing. You can register a personal collection interface through paybob to help sign up for personal Alipay and WeChat payment interfaces (no business license required), which can be opened in a few minutes , after applying for activation, obtain the merchant number and communication key, and then start the connection. This chapter mainly talks about scan code payment

Scan code payment request steps:

1. Construct request parameters

2. POST parameters to the request address

3. Display the QR code based on the returned content

4. Receive asynchronous notification after the user pays successfully


Scan the code to connect


## The php code is as follows:

```php

<?php

$order = [

'mchid' => 'xxxxxxxxxxxx',

'body' => 'test' , // Order title

'OUT_TRADE_NO' = & GT; Time (), // Order number

'Total_fee' = & GT; ## ];

$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;

}

```

- Replace the merchant number and communication key above with your own. Finally, the result returned by the QR code scanning interface can be printed out.

- In the result returned by the code scanning interface, the code_url is the QR code content, which can be converted into a QR code through the class generated by the QR code. Or the qrcode parameter returned by the interface is the image address of the QR code. The QR code is displayed to the user. The user can scan the code to pay through the scan function of WeChat on the mobile phone.

- It should be noted that asynchronous notification is not demonstrated in the above demo code. If you need asynchronous notification, you can add a notify_url parameter, then after the payment is completed, the server will receive an asynchronous notification of successful payment. You can further trigger and process business logic by yourself.

- Finally, I would like to share with you the general steps for signature generation as follows: (Detailed examples)

1. Suppose all the data sent or received is a set M, and the set M Parameters with non-empty parameter values ​​are sorted from small to large according to the ASCII code of the parameter name (lexicographic order), and are spliced ​​into a string stringA using the URL key-value pair format (i.e. key1=value1&key2=value2...).

2. At the end of stringA, splice the &key= key to get the stringSignTemp string, perform an MD5 operation on stringSignTemp, and then convert all the characters in the string to uppercase to get the sign value


I will continue to share with you the cashier mode and jsapi mode payment in the future, hoping to provide you with more reference.


嘟嘟嘟嘟1933 days ago1295

reply all(2)I'll reply

  • メ落尽丶天涯

    メ落尽丶天涯2019-07-30 00:14:12

    ***How ​​much is the handling fee!

    reply
    0
  • 嘟嘟

    The handling fee is 1%~2%. For details, please add lcm18939661958

    嘟嘟 · 2019-08-06 20:48:13
  • Cancelreply