Automatic micropayments

Developers can ask users to authorize automatic micropayments to their app. Once micropayments are authorized, the app can request and receive payments from the user's wallet without the user needing to confirm each transaction. The user can set limits on the size of each payment, and the cumulative amount.

This feature is very useful for apps requiring high frequency, low value transactions.

Step 1: Authorize micropayments

Redirect the client to the DotWallet automatic micropayment authorization screen

Param Required Description
app_id YES Application ID
redirect_uri YES Url to redirect client to after authorization

The DotWallet automatic micropayment authorization screen:

02paymentEntrance
  • User taps Continue

    	1. User decides what limit to put on individual transactions, and the cumulative total transaction value (default 0.01 and 0.1 BSV)
    	2. After the user confirms, the page will redirect to <font color=orange>{redirect_uri}</font>
    
02paymentAuth
  • User taps Refuse

The client will be redirected to {redirect_uri}

Failure example:

Error code Description
10003 Micropayment error, incorrect redirect_uri

Step 2: Initiate a micropayment

Param Required Type Description
app_id YES int Application ID
secret YES string Application secret key
merchant_order_sn YES string Order ID (recommended: UUID)
pre_amount YES int Payment amount (unit: satoshi)
user_open_id YES string User's global ID
item_name YES string Purchased item, product, or service name
opreturn NO string User provided custom OP_RETURN message/data (format: rawhex)
receive_address NO string Receiving wallet address. If left empty will send to app developer's default wallet as per the app settings

Note: receive_address must be a string that is a valid JSON array of objects such as the following:

[
  {
    "address": "1MS3HE9M3oEqW81KXp8iK9nBMTGXekdxAP",
    "amount": 622
  }
]

Success:

Note: "code" here is the error response code. 0 means success

{
  "code": 0,
  "msg": "",
  "data": {
    "order_sn": "ORDER_SN",
    "paytxid": "PAYTXID"
  }
}

Return params description:

Param Description
order_sn DotWallet generated order number
paytxid TXID (bitcoin transaction ID)

Failure example:

If the user is prompted that the balance is too low, please redirect them to Step 1

{
  "code": 10039,
  "msg": "Micropayment error, the current order number already exists",
  "data": []
}