1.项目根结点build.gradle文件中增加如下内容
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
2.项目主module的build.gradle文件中增加依赖
dependencies {
implementation 'com.github.Lxx2057:XxDoublePay:1.0'
}
在包名根目录下,新建wxapi文件夹,新建WXPayEntryActiv 内容如下
import com.xxl.doublepay.wxapi.WxPayEntryActivity
class WXPayEntryActivity : WxPayEntryActivity()
Manifest文件中添加如下代码
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent" />
XxDoublePay.intance.init(this)
XxDoublePay.intance.wxAppIDProvider = object : WxAppIDProvider {
override val weChatAppID: String
get() = "wx53fe2facdc1df93f"
}
XxDoublePay.intance
.openPay(payType, payInfo, object : XxAnyPayResultCallBack {
override fun onPaySuccess() {
Toast.makeText(this@MainActivity, "支付成功", Toast.LENGTH_SHORT).show()
}
override fun onPayFiale(error: String) {
Toast.makeText(this@MainActivity, error, Toast.LENGTH_SHORT).show()
}
})
XxDoublePay.intance
.openAliPay(payInfo, object : XxAnyPayResultCallBack {
override fun onPaySuccess() {
Toast.makeText(this@MainActivity, "支付成功", Toast.LENGTH_SHORT).show()
}
override fun onPayFiale(error: String) {
Toast.makeText(this@MainActivity, error, Toast.LENGTH_SHORT).show()
}
})
XxDoublePay.intance
.openWeChatPay(payInfo, object : XxAnyPayResultCallBack {
override fun onPaySuccess() {
Toast.makeText(this@MainActivity, "支付成功", Toast.LENGTH_SHORT).show()
}
override fun onPayFiale(error: String) {
Toast.makeText(this@MainActivity, error, Toast.LENGTH_SHORT).show()
}
})