版本要求
1.minSdkVersion 14+
接入流程
1.添加聚合支付(smpay)庫到你的項(xiàng)目中:
dependencies {
compile 'com.smpay:smpay:1.0.7'
}
2.在AndroidManifest.xml文件中:
?a.添加權(quán)限:
<uses-permission android:name="android.permission.INTERNET"/>
?b.注冊activity:
<activity
android:name="com.jy.smpay.H5PayWebActivity"
android:theme="@style/PayTheme"
android:screenOrientation="portrait" />
3.在style.xml文件中添加以下代碼
<style name="PayTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
4.在application中初始化sdk(這里的獲取請求訂單信息鏈接(REQUEST_PARAMS_URL)需要自己配置)
SMPaySDK.init(APPContants.REQUEST_PARAMS_URL);
5.調(diào)起支付界面:
SMPaySDK.startPay(context,REQUEST_PAY_CODE,orderListId,chanelType);
context:
orderId:需要支付的訂單id
REQUEST_PAY_CODE:調(diào)起支付的請求碼
chanelType:支付通道,暫時(shí)只有兩種微信掃碼支付("w-yun_wxscan")和快捷支付("mo_kj")
6.最后還需要在onActivityResult方法里面寫入下面代碼
switch (requestCode){
case REQUEST_PAY_CODE://支付結(jié)果回調(diào)
String payResult = data.getExtras().getString("pay_result");
break;
default:
break;
}
payResult:支付結(jié)果返回值(這里需要解析,具體可以參考demo里面的做法)