Android payment-precautions: android payment
Not all BAT APIs are so easy to use. There are a lot of pitfalls in payment. Let's summarize the pitfalls in payment implementation.
Point 1:
Generation of the PayReq parameter sign
The PayReq object has a parameter packageValue.
PackageValue is used when sign is generated, but the corresponding Key is package. The key here is easy to make a mistake.
List<NameValuePair> signParams = new LinkedList<NameValuePair>();signParams.add(new BasicNameValuePair("appid", req.appId));signParams.add(new BasicNameValuePair("noncestr", req.nonceStr));signParams.add(new BasicNameValuePair("package", req.packageValue));signParams.add(new BasicNameValuePair("partnerid", req.partnerId));signParams.add(new BasicNameValuePair("prepayid", req.prepayId));signParams.add(new BasicNameValuePair("timestamp", req.timeStamp));
Point 2:
Payment callback Method
Use reflection to find the corresponding class and implement the callback
The official descriptions are as follows:
Refer to the SDK Sample in. net. sourceforge. simcpux. implement the WXPayEntryActivity class in the wxapi package path (inconsistent package names or class names will cause callback failure). Implement the onResp function in the WXPayEntryActivity class. After the payment is complete, the APP returns to the merchant APP and calls back the onResp function. The developer needs to receive the notification in the function to determine whether the error code is returned. If the payment is successful, go to the background to query the payment result and then display the user's actual payment result.
Meaning:
1. You need to create a packageName +. wxapi package, for example, your project registration: com. android. qq. Then you need to create a wxapi package under the package name.
2. Create an Activity class named WXPayEntryActivity under the package and implement the interface IWXAPIEventHandler. The payment callback is carried out in the onResp (BaseResp resp) method of the interface.
package com.android.qq.wxapi;public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
@ Overridepublic void onResp (BaseResp resp) {// process the payment callback}
}
III:
Signature Test
This is not a pitfall. Many third parties have to test it in this way.
The paid test must correspond to the signed package; otherwise, the payment function cannot be tested.