Skip to content

Latest commit

 

History

History
115 lines (101 loc) · 4.47 KB

README.md

File metadata and controls

115 lines (101 loc) · 4.47 KB

QSPay

zfb wx union License

😀安卓一行代码☕搞定微信、支付宝、银联支付

Gradle

//build.gradle
allprojects {
    repositories {
        maven {
            url "https://jitpack.io"
        }
    }
}
//app.gradle
dependencies {
    //核心包必选
    implementation 'com.github.tohodog.QSPay:core:2.0'
    //根据需求选择使用
    implementation 'com.github.tohodog.QSPay:wxpay:2.0' //微信
    implementation 'com.github.tohodog.QSPay:alipay:2.0' //支付宝
    implementation 'com.github.tohodog.QSPay:uppay:2.0' //银联
}

启动支付API

    public void paySdk(PayInfo payInfo, PAY_TYPE pay_type) {
        PayAPI.get(this, pay_type).pay(payInfo, new PayCallback() {
            @Override
            public void onComplete(PAY_TYPE payType, String result) {
                Toast.makeText(MainActivity.this, "支付成功", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onFail(PAY_TYPE payType, String msg) {
                Toast.makeText(MainActivity.this, "支付失败", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onCancel(PAY_TYPE payType) {
                Toast.makeText(MainActivity.this, "支付取消", Toast.LENGTH_LONG).show();
            }
        });
    }

微信支付

        //参数由后台接口生成
        WXPayInfo payInfo = new WXPayInfo();
        payInfo.appId = "wx41acb06b6a756b80";
        payInfo.prepayId = "wx0909150675574360653f9b341120102000";
        payInfo.partnerId = "1523993851";
        payInfo.nonceStr = "a01427863e3940699c9ac29442e0770b";
        payInfo.timeStamp = "1594257306";
        payInfo.packageValue = "Sign=WXPay";
        payInfo.sign = "8418D3E4C36B1E3A956763D71BBBF6DC";
        paySdk(payInfo, PAY_TYPE.WEIXIN);
        
        //微信需要在自己项目包名下新建wxapi文件夹,然后新建一个Activity继承QSPayEntryActivity
        public class WXPayEntryActivity extends QSPayEntryActivity {
        }
        //AndroidManifest.xml配置
        <activity
            android:name=".wxapi.WXPayEntryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:exported="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

支付宝支付

        //参数由后台接口生成
        AliPayInfo payInfo = new AliPayInfo();
        // payInfo.testMode = true;//沙箱模式
        payInfo.payParam = "alipay_sdk=alipay-easysdk-java-2.0.0&app_id=2019091767145019&biz_content=%7B%22out_trade_no%22%3A%22102020070909062278810001%22%2C%22total_amount%22%3A%220%22%2C%22subject%22%3A%22test%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&notify_url=https%3A%2F%2Fapi.reol.top%2FpayNotify%2FaliPay&sign=KRB3zZQQ7JeEeoHOJWwCSQaJ6ehv1I7WHSHtzJ4Y9pjq2HzBVR%2B5Mq9Z9%2BInAK%2Fcr%2Bc4pOiiJjPqdp61sUkrcWomPGjwFrObMC3xj29PeOBv%2FFCvR9UvRbIUr1tQ7El7YP8sSCRsI7BsBvHNhaxEz%2Ft6CvEAfchei28eC658cJvijw3FnYYVdRA2jBhU4YqTWM%2Ft9HEwBq5KGy8c9cOyyLvS9Hg0pAORVGkpSc9%2B8Rv0kwtmWsojoTTQZvHePYoWlXoR07WJxgOWcxLbMJ%2FASqDs5P1fBaoQLXJfbkQk1c%2Fx3sBnHWWuW%2FL%2BhtbikFX%2FkN9dJcLwuXauNyU9ls1Oog%3D%3D&sign_type=RSA2&timestamp=2020-07-09+09%3A06%3A22&version=1.0";
        paySdk(payInfo, PAY_TYPE.ALIPAY);

银联支付

        UPPayInfo upPayInfo = new UPPayInfo();
        upPayInfo.tn = "989239916971662107220";
        // upPayInfo.testMode = true;//测试模式
        paySdk(upPayInfo, PAY_TYPE.UPPAY);

Log

v2.0(2021-11-17)

  • 架构更改,可单独导入需要的支付模块
  • 升级支付SDK到最新版本

v1.0.0(2020-07-09)

  • 支持微信,支付宝,银联支付

Other

  • 有问题请Add issues
  • 如果项目对你有帮助的话欢迎star