Detailed WeChat applet call payment interface payment

I did WeChat payment before, I met a lot of pit, I didn’t explain the online, I didn’t have the experience of all walks of life, I finally finished, I have a lot of explanations on the Internet. I only talk about some attention. And solutions. I will talk about the process I have completed from completely.

A WeChat payment interface is provided in the interface document provided by WeChat, which should be invoked directly to initiate WeChat payment

Document path: https: //developss.weixin.qq. Com / miniprogram / dev / api / api-pay.html # wxrequestpaymentObject

详解微信小程序调用支付接口支付

But when the confidence is full, it is forced, these What is the most difficult understanding and acquisition in these parameters, it is two, and then discovered carefully. The acquisition of Package should call WeChat. An interface, unified single interface. It turns out that the payment needs to be paid in WeChat. The timestamp here is the second value, not millisecond value

Document path: https: //pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php? Chapter = 9_1

详解微信小程序调用支付接口支付

This interface needs to be adjusted by the HTTP request to adjust

, there are two parameters. I am very familiar, there are two parameters when I initiated WeChat request, and then found that the random string here is the random string used in the payment, and it must be consistent, then the signature, if it is also considered I have completely adjusted, and the signature here is called a signature because the second signature is required. The signature generation algorithm has a explanation, read more than a few times, I suggest reading a few tens of times.

详解微信小程序调用支付接口支付 Prepare these required parameters

It is very important that you have to have a store first, there is a merchant.

The order number must be unique, the notification address is that WeChat will call this address when the payment is successful, where you can do something, such as modifying the order status. 详解微信小程序调用支付接口支付

Then the signature generation, this is important: put the required parameters in a map, then sort these parameters, then put the product key to the back to make MD5 encryption to generate a signature, I still It is recommended to take a closer look at the signature generating algorithm. Don’t think too complicated, it is sorted, spliced, and the encryption is completed.

The last is to prepaid parameters. The parameter transmission here is transmitted in XML. The following is the data transmitted, is actually a large string,

You can do this

String s = “

” + “

wxdxxxxxxxxx

” + “

10000100

” + “

24jtlk2j3ltjl2kjlkt3j

” + “
432L4J5J4325L23K4J5J4325L23K4J5LJ34 ” + “
      I mean, everyone knows, In fact, it is a string that can be spliced ​​by traversal parameters.   Then it passes this big character, and if there is no problem, it will return a string XML, the format type, our stitching parameters.     From the things we need, the most important thing should be this, pre-prescribed single ID, this is the previously needed package  
Such: package = ‘prepay_id = 201411109120471241k1241240124bk1k24’
Then the second signature, the signature generation order is the same, mainly to determine the needWhat parameters are you going.

详解微信小程序调用支付接口支付

Then return these parameters to the front desk, and take it out.

When the front end calls it will be paid. 详解微信小程序调用支付接口支付

Welcome to ask questions

The above is the WeChat applet to send the WeChat applet to the WeChat applet to pay the detailed integration, I hope that everyone can help, if you have any questions Leave me a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment