Android integrated wechat payment function

The preparatory work is not mentioned here, including signing a contract and applying for appid. The development steps of wechat open platform app are attached. Students who do not understand can refer to here:

https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_ five

The above steps are very detailed. Here we mainly talk about the precautions for lowering the payment. According to the above document, the merchant server generates the payment order, first calls the unified order API to generate the prepayment order, and obtains the prepayment_ After ID, the parameter is signed and transmitted to the app again to initiate payment.

Relevant codes are as follows:

Relevant parameter descriptions are indicated in the document. I have nonce here_ STR and out_ Trade_ No is my randomly generated character creation. My tool class is attached for your reference.

ResourceUtil.java

For the generation of sign, the order of parameters must be in strict accordance with the above order, add key for MD5 encryption, and view the signature specification. For the description of keys, the keys here need to be generated and configured to the wechat open platform. Refer to the generation and setting of merchant payment key keys for configuration. Both sides need to be consistent. In addition, when placing an order, the parameters should be passed in XML format.

Finally, attach your signature algorithm:

SignUtil.java

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>