Current location - Quotes Website - Personality signature - Android WeChat payment process from background to front end
Android WeChat payment process from background to front end
Wechat payment requires the following three parameters. Please refer to the official instructions for the specific acquisition process.

Add a dependency package:

Compile' com.tencent.mm.opensdk: wechat-sdk-Android-with-MTA:+

The App sends the order parameters to the background through the interface, and the background calls the WeChat unified ordering interface to get the id(prepayid order id, and returns the parameters to the App after signing.

Assembly unified ordering parameters:

Send a unified order request to the WeChat background, and the parameters are in xml format:

The data returned by WeChat backstage is also in xml format. After the parameters are signed (note the field names), they will be returned to the application:

After obtaining the returned data from the background, initiate payment:

Processing payment results:

Record the new wxapi package in the package name, put WXPayEntryActivity into the official demonstration, and register it in manifest:

The WXPayEntryActivity interface can also be customized, but the package name and class name cannot be changed. Override the onResp(BaseResp resp) method to process the results: