/v2/miniprogram/qrcode/create

POST /v2/miniprogram/qrcode/create

The create  API is used to create the QR code value and return it to the merchant. The merchant then uses the QR code value to generate the URL for QR code images.

Message structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:

Request

Property

Data type

Required

Description

Example

appId

String 

Yes

The Mini-Program App ID.

Max. length: 32 characters.

"P000000000000001xxxx"

urlParameter

String 

Yes

Is a page path that can be accessed by a Mini-Program, for example:

page/component/component-pages/view 

Max. length: 256 characters.

"page/component/component-pages/view"

queryParameter

String 

Yes

The launch parameters for Mini Program. When Mini Program starts up, the queryParameter  is passed to it; and this parameter can be obtained via the Mini Program onLaunch method.

Max. length: 64 characters.

"x=1"

description

String 

Yes

The QR code description.

Max. length: 64 characters.

"My shop QR code"

extendInfo

String

No

The extension information that wallets and merchants want to describe.

Max. length: 4096 characters.

copy
{
    "memo": "memo"
}

Response

Property

Data type

Required

Description

Example

result

Result

Yes

The request result, which contains status and error codes.

{

   "resultCode": "SUCCESS",

   "resultStatus": "S",

   "resultMessage": "success"  

 }

qrcode

String

Yes

The QR code value

Max. length: 1024 characters.

"https://miniprogram.alipay.com/mini-qr/28166612109YMP7RLw7zT2HU1k6AXzSOFfv4qu3xxxx"

Result Process Logic

In the response, the result.resultStatus field indicates the result of processing a request as follows.

resultStatus

Description 

S

The request is successful. The QR code value is generated and returned to the merchant. The merchant can use the QR code value to generate the URL for QR code images.

The corresponding result.resultCode is "SUCCESS" and the result.resultMessage  is "Success".

U

The API status is unknown.  

The corresponding result.resultCode is "UNKNOWN_EXCEPTION" and result.resultMessage  is "An API calling is failed, which is caused by unknown reasons."

For details, see the Common error codes section.

F

The request fails to send.

The corresponding result.resultCode  and result.resultMessage are various based on different situations. For details, see the following Error codes section.

Error codes

Error codes are usually classified into the following categories:

  • Common error codes are common for all Mini Program OpenAPIs.  
  • API-specific error codes: the current OpenAPI does not have its dedicated error codes.

Sample

/v2/miniprogram/qrcode/create
  1. Create the QR code value.
  2. Return the generated QR code value to the merchant.

Request

copy
{
    "appId": "P000000000000001xxxx",
    "urlParameter": "page/component/component-pages/view",
    "queryParameter": "x=1",
    "description": "My shop QR code"
}

Response

copy
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S"
 },
 "qrcode": "https://miniprogram.alipay.com/mini-qr/28166612109YMP7RLw7zT2HU1k6AXzSOFfv4qu3xxxx"
}