Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development WeChat payment


May 20, 2021 WeChat Mini Program Development Document


Table of contents


WeChat payment

Starting with developer tool 1.02.2005111, the cloud console supports cloud development WeChat payment merchant binding, which can be natively connected to WeChat payment in cloud development after binding:

  1. Signature-free: All interfaces are signature-free and get the parameters required for the applet wx.requestPayment directly
  2. Receive callbacks: Cloud functions support receiving asynchronous payment result callbacks

WeChat small program cloud development WeChat payment

Qualification

The need is that WeChat payment has been opened, and the merchant number has been bound to the small program.

Opened

It's on in the cloud console - settings -

Permissions

Account binding, jsapi, and api refund permission authorization are required after the merchant number is added. Please note:

1) Account binding: you need to confirm the authorization on the WeChat Payment Merchant Assistant program provided by WeChat Payment.

2) jsapi and api refund permissions, you need to go to WeChat Payment Merchant Platform my authorized products to confirm authorization. Description

After the authorization is completed, weChat payment-related interface capabilities can be invoked.

Interface

wx-server-sdk >= 2.0.2

Cloud Development provides WeChat payment-related interface and service-side callbacks, including unified order orders, query orders, close orders, request refunds, query refunds, download statements, as detailed in the API documentation.

Order critical development processes:

  1. The applet calls the cloud function, calls the unified order interface in the cloud function, and the parameters carry the name of the cloud function receiving the asynchronous payment results and the cloud environment ID in which it is located
  2. The unified order interface returns a successful result object with the payment field, which is all the information required for the interface (wx.requestPayment) that the small terminal initiates the payment
  3. The small terminal gets the results of the cloud function and calls wx.requestPayemnt to initiate the payment
  4. Once the payment is complete, the cloud function configured in the unified order interface will be notified of the payment results

Note: The cloud function that receives the payment result callback must return an object for "errcode": 0, otherwise the callback processing will be considered a failure and the callback will continue to be received for the next two days until the return is successful. The specific return value protocol can be found in the unified order interface documentation.