客户端接入(安卓:微信,支付宝)
安卓客户端接口人: 刘贝liubei@wifi.com
配置 AndroidManifest.xml
必须完成 基本接入步骤(必接) 相应的配置项,除此之外还需要配置
<manifest … >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.wifi.open.xpay.PayActivity"
android:theme="@style/Theme_Transparent_Pay" />
<!-- 必须是应用包名下wxapi包内建同名WXPayEntryActivity,
此Activity只需继承自com.wifi.open.xpay.PayResultActivity, 无需其他任何实现-->
<activity android:name="{应用包名}.wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop"/>
…
</application>
</manifest>
导入资源文件
- 将res-pay.zip解压后合并到App工程目录下的res目录中
- 将pay-libs/alipaySdk-20151215.jar和wechat-sdk-android-without-mta-5.1.6.jar放到工程目录libs下
调用收银台界面 PayParam
//支付时传入payParam JSON字符串,参数见上面链接
WKXPay.pay(activity, payParam, new XPay.Callback() {
@Override
public void onPayResult (int payStatus, String msg){
Log.e("XPay", "pay result: " + payStatus + "; msg:" + msg);
}
});
PayStatus
参数值 | 参数名称 | 描述 |
---|---|---|
0 | PAY_CANCEL | 支付取消 |
1 | PAY_SUCCESS | 支付成功 |
-1 | PAY_INVALID | 支付无效,不需要等待结果,一定是失败的 |
-2 | PAY_ERROR | 支付异常,可能支付成功也可能支付失败 |
2 | PAY_LIFE_CYCLE | 支付页面生命周期 |
设置生产\测试环境
XPayConfig.IS_TEST = BuildConfig.DEBUG;
混淆设置
# Alipay
-dontwarn android.net.**
-keep class android.net.SSLCertificateSocketFactory{*;}
-keep class com.alipay.android.app.IAlixPay{*;}
-keep class com.alipay.android.app.IAlixPay$Stub{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
-keep class com.alipay.sdk.app.PayTask{ public *;}
-keep class com.alipay.sdk.app.AuthTask{ public *;}
-keep class com.alipay.sdk.app.H5PayCallback {
<fields>;
<methods>;
}
-keep class com.alipay.android.phone.mrpc.core.** { *; }
-keep class com.alipay.apmobilesecuritysdk.** { *; }
-keep class com.alipay.mobile.framework.service.annotation.** { *; }
-keep class com.alipay.mobilesecuritysdk.face.** { *; }
-keep class com.alipay.tscenter.biz.rpc.** { *; }
-keep class org.json.alipay.** { *; }
-keep class com.alipay.tscenter.** { *; }
-keep class com.ta.utdid2.** { *;}
-keep class com.ut.device.** { *;}
# Weixin Pay
-keep class com.tencent.mm.opensdk.** {*;}
-keep class com.tencent.mm.sdk.** {*;}