Summary of key points of Android developing wechat app payment function

Basic concepts

The package name is the package of your app, which is set when creating the project, and needs to be set on the wechat payment platform.

Signature refers to the MD5 of the signature file you use when generating APK. Remove: all in lowercase and need to be set on the wechat payment platform.

In the debugging phase, the debug.keystore for debugging can be used for the signature file. The signature can be viewed directly on eclipse or with tools. You can view it by entering the package name after installation.

When publishing, you must set the signature value for publishing on the wechat payment platform.

The contents of the official demo are not all necessary. Even libammsdk.jar is enough, and androidmanifest.xml does not need to be configured.

The configuration of androidmanifest.xml and wxpayentryactivity.java are just to get the payment callback. You can ignore it and debug whether the payment can be initiated first.

Copy libammsdk.jar to LIBS of your project and add jar reference.

Initiate payment request in Code:

The relevant pre order ID, signature and timestamp in the above code are returned by the server. The server needs to pay attention to the problem of secondary signature when generating these values.

Normally, the wechat client will open the payment page, so you can start callback again. Copy wxpayentryactivity.java to the wxapi folder under your project package. For example, if your package name is com.xx.shop, put it under com.xx.shop.wxapi. Set androidmanifest.xml to support callbacks:

Wxpayentryactivity.java does not need a layout file, or it can be laid out according to your needs.

For debugging convenience, the onresp code in wxpayentryactivity.java is changed to:

Whether the payment is successful or not, if the onresp code can be executed automatically, it indicates that the configuration in your androidmanifest.xml is correct.

If you have a good grasp of your parameters (for example, your IOS group can pay, but your Android is still in the hole), take a look at API. Registerapp (values. Wxpayappid); Yes, yes, I died here. In this case, I can open the payment interface for the first time (very occasionally), but I can't do it later.

summary

Why can't wechat give a detailed error code or description? Just give a - 1. God knows what it means. It's really annoying. The above is all about the key points of Android's development of wechat app payment function. I hope the content of this article can help you develop Android.

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
分享
二维码
< <上一篇
下一篇>>