Start payment interface

Start payment interface (interface required)

You have 2 ways to use this interface: 1. Jump to our official payment page, our payment page supports PC and mobile interface adaptation, scan code payment on PC, H5 payment on mobile phone; 2. Custom payment page On your own payment page, the payment QR code will be displayed on the PC, and the corresponding address of the QR code will be automatically jumped on the mobile phone, then B.APP can be transferred to complete the H5 payment.

Interface URL:

https://bapi.app/api/v2/pay

Transfer method::POST

Usage: Your server (server) will post the parameters to our specified interface in json format. After success, the interface will return a json string, you can jump the user's browser to the URL of the returned pay_url parameter value, let the user enter the official payment page payment (relatively simple); or on their own custom payment page (relative Complex), directly generate the QR code of the returned qr_code parameter value and display it on the payment page; if it is the mobile terminal, you can directly jump to the URL of the qr_code parameter value, and the B.APP client will be called to perform H5. Pay

After the user's payment is successful, we will send a callback notification for the successful payment of this order to your notify_url.

Parameter request

All the following parameters, 1 Chinese character, 1 English letter, 1 punctuation mark, 1 space, only 1 character

Parameters Required Types Description
order_id Required string(32) The merchant order number, up to 32 characters, please ensure the uniqueness of the order number
amount_type Required string(16) The currency unit of the order, currently only supports RMB, so it will only be: CNY
amount Required long The order amount,unit (RMB: cent) , for example: 5.00 yuan here please use 500, note the necessary: amount > 0
body Required string(128) The product name, UTF8 format, is used to display the location of the product name on the payment page, as well as the list of orders in your business backend.
return_url Required string(256) After the payment is successful, the address will be jumped. Note: Required when using the official payment page; custom payment page can be left blank. After the user has successfully paid, we will automatically jump to the URL of the user's browser. Note that this parameter does not urlencode. Example: https://www.aaa.com/pay_return
notify_url Required string(256) The notification address will be recalled after the payment is successful. Once the user successfully pays, our server will asynchronously send a callback notification to this URL. The specific parameters, please see here.if the callback notification fails, will be retried 5 times according to the time, respectively: 5 seconds after the first callback failure of the order, 10 seconds , 30 seconds, 1 minute, 5 minutes. After retrying 5 times, the notification is still unsuccessful and will not be automatically retried. You can use the query interface to determine whether the success is successful. Note that this parameter does not urlencode-. Example: http://www.aaa.com/pay_notify
time Required long The server time when initiating payment, with 13-bit timestamp, is used for security reasons to defend against request resend attacks
app_key Required string(16) The APP key is generated by the platform. Get in "Business Backend - Business Information
sign Required string(32) Sign it, then click here to view the signature generation method
order_ip Optional string(45) The order originator ip (user's ip), such as: 114.114.114.114, also supports IPV6, convenient for your own wind control
extra Optional string(64) The additional parameters, the payment will be returned as it is, up to 64 characters

Example request

curl -X POST -H 'content-Type:application/json' -d '{"sign":"c99b0c73796ef1ead15a140e76542689","order_id":"1","amount":1,"time":1234567890123,"app_key":"4789e57f8629eb9e","body":"goods_name","notify_url":"https://bapi.app/api/experience/notify/test","return_url":"https://baidu.com"}' https://bapi.app/api/v2/pay
              

The Interface return parameter

Parameter format:application/json

Parameters Types Description
code int The status code, 200 means successful acquisition, other status codes, please refer to the information content returned by msg
msg string Prompt message
data.qr_code string You can customize the information displayed on the payment page. This parameter will be generated on the PC to generate the QR code. The mobile browser can open this address directly to transfer the B.APP to complete the payment.
data.pay_url string The official payment page URL address, directly transfer the user client to this address to pay

The Interface return example

  1. {
  2. "code": 200,
  3. "msg": "ok",
  4. "data": {
  5. "qr_code": "HTTPS://QR.B.APP/pay?sid=100001&oi=201906191404051de88e",
  6. "pay_url": "http://bapi.app/h5.html?order_no=201906191404051de88e&sign=8642f2b9&v=20190613"
  7. }
  8. }