Low-code development, fast docking with WeChat payment

aims:

Implement the WeChat payment function in the WeChat webpage to achieve the purpose of placing an order;

Implementation environment:

White code low code platform:https://www.bnocode.com/product.html
enables the API provided by the platform to implement the WeChat payment function, which can be directly called, reducing a lot of debugging time

Platform language:

node.js

Ready to work:

  1. A WeChat official account administrator account
  2. A WeChat payment account
  3. Prepare product and order data tables in the system

Implementation steps:

1. Build a simple custom page, mainly used for order
Low-code development, fast docking with WeChat payment
placement ; 2. Create an API and a webhook to initiate payment and callback payment; (According to the official instructions, the API that initiates WeChat payment will return a configuration JSON , Used for the front-end to initiate payment)
Low-code development, fast docking with WeChat payment
Low-code development, fast docking with WeChat payment
Low-code development, fast docking with WeChat payment
Low-code development, fast docking with WeChat payment
3. Build an order function, the function will call the API to initiate the payment, the front-end page will call the function, set the function return value to the parameter returned by the API, and the front-end uses the return value to initiate the payment ;
Low-code development, fast docking with WeChat payment
4. Go back to the custom page created earlier and write the code for the order function. The idea is to get the openid of the current WeChat user (parameters required to initiate payment), call the order creation function to initiate WeChat payment, and get the function return value , Use the return value to call the payment;
Low-code development, fast docking with WeChat payment
5. After the payment is initiated, the webhook will always be touched. The webhook request body contains the order number and payment result of the payment. You need to update the status of the corresponding order according to the order number and result, return to the webhook, and continue to write and update The code of the order status;
Low-code development, fast docking with WeChat payment
6. To test the effect, I obtained a link with a specific format by asking the customer service. After WeChat enters the link, the front end can obtain the openid, and the WeChat payment can be made;
Low-code development, fast docking with WeChat payment
Low-code development, fast docking with WeChat payment

Guess you like

Origin blog.51cto.com/14903387/2534846