├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cuieney
│ │ └── android
│ │ └── rxpay
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── cuieney
│ │ │ └── android
│ │ │ └── rxpay
│ │ │ ├── JavaSampleActivity.java
│ │ │ ├── KotlinSampleActivity.kt
│ │ │ └── RxPayApplication.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── cuieney
│ └── android
│ └── rxpay
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
├── logo.png
├── myWechat.png
├── ssh_adb.sh
└── wechat.png
├── rxpay-annotation
├── .gitignore
├── build.gradle
├── mavenpush.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── cuieney
│ └── rxpay_annotation
│ └── WX.kt
├── rxpay-api
├── .gitignore
├── build.gradle
├── build
│ ├── generated
│ │ └── source
│ │ │ ├── buildConfig
│ │ │ └── debug
│ │ │ │ └── com
│ │ │ │ └── cuieney
│ │ │ │ └── sdk
│ │ │ │ └── rxpay
│ │ │ │ └── BuildConfig.java
│ │ │ └── r
│ │ │ └── debug
│ │ │ └── com
│ │ │ └── cuieney
│ │ │ └── sdk
│ │ │ └── rxpay
│ │ │ └── R.java
│ └── intermediates
│ │ ├── bundles
│ │ └── debug
│ │ │ ├── R.txt
│ │ │ └── res
│ │ │ └── values
│ │ │ └── values.xml
│ │ ├── incremental
│ │ ├── compileDebugAidl
│ │ │ └── dependency.store
│ │ └── packageDebugResources
│ │ │ ├── compile-file-map.properties
│ │ │ ├── merged.dir
│ │ │ └── values
│ │ │ │ └── values.xml
│ │ │ └── merger.xml
│ │ └── manifests
│ │ └── aapt
│ │ └── debug
│ │ └── AndroidManifest.xml
├── libs
│ └── alipaySdk-20180601.jar
├── mavenpush.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cuieney
│ │ └── sdk
│ │ └── rxpay
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── cuieney
│ │ │ └── sdk
│ │ │ └── rxpay
│ │ │ ├── PayWay.kt
│ │ │ ├── PaymentStatus.kt
│ │ │ ├── RxBus.kt
│ │ │ ├── RxPay.kt
│ │ │ ├── alipay
│ │ │ ├── AlipayWay.kt
│ │ │ └── PayResult.kt
│ │ │ └── wechatpay
│ │ │ ├── NameValuePair.kt
│ │ │ └── WXPayWay.kt
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── cuieney
│ └── sdk
│ └── rxpay
│ └── ExampleUnitTest.java
├── rxpay-compile
├── .gitignore
├── build.gradle
├── mavenpush.gradle
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── cuieney
│ │ └── rxpay_compile
│ │ ├── Constant.kt
│ │ ├── GenerateWXActivityHelper.kt
│ │ └── WxPayActivityProcessor.kt
│ └── resources
│ └── META-INF
│ └── services
│ └── javax.annotation.processing.Processor
├── settings.gradle
└── wechat.png
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /.idea
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## What's RxPay ?
4 |
5 | **让支付从此简单下去,一键支付功能,支持支付宝支付,微信支付**
6 |
7 | #### 集成步骤
8 |
9 | > Java 项目配置
10 |
11 | ```
12 | dependencies {
13 | compile 'com.cuieney:rxpay-api:2.2.3'
14 | annotationProcessor 'com.cuieney:rxpay-compiler:2.1.1'
15 | //如果你项目配置了kotlin请忽略下面这行的配置
16 | //否则会报错 Failed resolution of: Lkotlin/jvm/internal/Intrinsics
17 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
18 | }
19 | ```
20 |
21 | > Kotlin 项目配置
22 |
23 | ```
24 | apply plugin: 'kotlin-kapt'
25 |
26 | dependencies {
27 | compile 'com.cuieney:rxpay-api:2.2.3'
28 | kapt 'com.cuieney:rxpay-compiler:2.1.1'
29 | }
30 | ```
31 |
32 | ### 添加权限
33 | ```
34 |
35 |
36 |
37 |
38 |
39 | ```
40 |
41 | ### 支付宝
42 |
43 | > 清单文件注册支付宝相关 Activity
44 |
45 | ```
46 |
47 |
53 |
59 | ```
60 |
61 | > 发起支付宝支付
62 |
63 | ```
64 | new RxPay(this)
65 | .requestAlipay("服务器产生的订单信息")
66 | .subscribe(new Consumer() {
67 | @Override
68 | public void accept(Boolean aBoolean) throws Exception {
69 | payState.setText("阿里支付状态:"+aBoolean);
70 | }
71 | }, new Consumer() {
72 | @Override
73 | public void accept(Throwable throwable) throws Exception {
74 | payState.setText("阿里支付状态:"+throwable.getMessage());
75 | }
76 | });
77 | ```
78 |
79 | #### 微信
80 |
81 | > 在 Application 类中添加支付节点
82 |
83 | ```
84 | @WX(packageName = "微信支付注册keystore时候的包名")
85 | public class XXApplication extends Application {
86 |
87 | }
88 | ```
89 |
90 | > 在AndroidManifest添加你微信支付的appid 和PARTNER_ID商户号(固定不变的),apiKey(商户平台设置的密钥key获取方法,可以问后台要可以到微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置)
91 |
92 | ```
93 |
94 |
97 |
98 |
99 |
102 |
103 |
104 |
107 | ```
108 |
109 | > 在清单文件中注册微信相关的Activity,添加完之后会报错,使用 ReBuild 或者重新运行就不会了,这个 Activity 会被自动生成
110 |
111 | ```
112 |
117 | ```
118 |
119 | > 发起微信支付
120 |
121 | ```
122 | new RxPay(this)
123 | .requestWXpay(("服务器生成订单的后拼接成下面这种json字符串"))
124 | .subscribe(new Consumer() {
125 | @Override
126 | public void accept(Boolean aBoolean) throws Exception {
127 | payState.setText("微信支付状态:"+aBoolean);
128 | }
129 | }, new Consumer() {
130 | @Override
131 | public void accept(Throwable throwable) throws Exception {
132 | payState.setText("微信支付状态:"+throwable.getMessage());
133 | }
134 | });
135 | ```
136 |
137 | > 对应的json格式参考
138 |
139 | ```
140 | 1.格式一(Manifest三个参数全设置了)
141 | {
142 | "prepayId": "必填项",
143 | }
144 | 2.格式二(Manifest设置了PARTNER_ID 没有设置API_KEY)
145 | {
146 | "nonceStr": "必填项",
147 | "partnerId": "必填项",
148 | "packageValue": "必填项",
149 | "prepayId": "必填项",
150 | "sign": "必填项",
151 | "timeStamp": "必填项"
152 | }
153 | ```
154 |
155 | [示例代码](app/src/main/java/com/cuieney/android/rxpay)
156 |
157 | #### 混淆规则
158 |
159 | ```
160 | -keep class com.alipay.android.app.IAlixPay{*;}
161 | -keep class com.alipay.android.app.IAlixPay$Stub{*;}
162 | -keep class com.alipay.android.app.IRemoteServiceCallback{*;}
163 | -keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
164 | -keep class com.alipay.sdk.app.PayTask{ public *;}
165 | -keep class com.alipay.sdk.app.AuthTask{ public *;}
166 | -keep class com.alipay.sdk.app.H5PayCallback {
167 | ;
168 | ;
169 | }
170 | -keep class com.alipay.android.phone.mrpc.core.** { *; }
171 | -keep class com.alipay.apmobilesecuritysdk.** { *; }
172 | -keep class com.alipay.mobile.framework.service.annotation.** { *; }
173 | -keep class com.alipay.mobilesecuritysdk.face.** { *; }
174 | -keep class com.alipay.tscenter.biz.rpc.** { *; }
175 | -keep class org.json.alipay.** { *; }
176 | -keep class com.alipay.tscenter.** { *; }
177 | -keep class com.ta.utdid2.** { *;}
178 | -keep class com.ut.device.** { *;}
179 |
180 | -dontwarn com.alipay.**
181 | ```
182 | #### 其他问题
183 |
184 | * 对于调起微信支付的json的字段请参考以上的json
185 |
186 | * 以下的过度版本可以解决依赖包冲突问题
187 |
188 | * com.cuieney:rxpay-api:**2.1.11** 版本 **阿里jar包 微信依赖** **都已剔除**
189 |
190 | * com.cuieney:rxpay-api:**2.1.12** 版本**只剔除 阿里jar包**
191 |
192 | * com.cuieney:rxpay-api:**2.2.2** 版本**只剔除 微信依赖**
193 |
194 | * 如果项目中还有Rxjava版本1的话为了防止代码冲突 请在build.gradle里面添加一下代码
195 |
196 | ```
197 | packagingOptions {
198 | exclude 'META-INF/rxjava.properties'
199 | }
200 | ```
201 |
202 | #### 问题
203 |
204 | 发现bug或好的建议欢迎 [issues](https://github.com/Cuieney/RxPay/issues) or
205 | Email
206 |
207 | ### License
208 |
209 | ```
210 | Copyright 2017 Cuieney
211 |
212 | Licensed under the Apache License, Version 2.0 (the "License");
213 | you may not use this file except in compliance with the License.
214 | You may obtain a copy of the License at
215 |
216 | http://www.apache.org/licenses/LICENSE-2.0
217 |
218 | Unless required by applicable law or agreed to in writing, software
219 | distributed under the License is distributed on an "AS IS" BASIS,
220 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221 | See the License for the specific language governing permissions and
222 | limitations under the License.
223 | ```
224 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 | apply plugin: 'kotlin-kapt'
7 | android {
8 | compileSdkVersion 26
9 | defaultConfig {
10 | applicationId "com.cuieney.android.rxpay"
11 | minSdkVersion 15
12 | targetSdkVersion 26
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(include: ['*.jar'], dir: 'libs')
27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
29 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:0.5'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
33 |
34 | // api('com.cuieney:rxpay-api:2.1.8')
35 | // kapt 'com.cuieney:rxpay-compiler:2.1.1'
36 |
37 | api project(':rxpay-api')
38 | kapt project(':rxpay-compile')
39 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/cuieney/android/rxpay/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.android.rxpay
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.cuieney.android.rxpay", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
32 |
35 |
36 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cuieney/android/rxpay/JavaSampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.cuieney.android.rxpay;
2 |
3 | import android.os.Bundle;
4 | import android.os.Handler;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 |
10 | import com.cuieney.rxpay_annotation.WX;
11 | import com.cuieney.sdk.rxpay.RxPay;
12 |
13 | import org.json.JSONException;
14 | import org.json.JSONObject;
15 |
16 | import io.reactivex.disposables.Disposable;
17 | import io.reactivex.functions.Consumer;
18 | import io.reactivex.schedulers.Schedulers;
19 |
20 | public class JavaSampleActivity extends AppCompatActivity {
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | findViewById(R.id.ali).
26 | setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | alipay();
30 | }
31 | });
32 |
33 | findViewById(R.id.wechat).setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View view) {
36 | wechatPay();
37 | }
38 | });
39 | new Handler();
40 | }
41 |
42 | void alipay() {
43 | //服务器产生的订单信息
44 | String str = "partner=\"2088121059329235\"&seller_id=\"1993349866@qq.com\"&out_trade_no=\"XGJ_LIVE20171130142905-440402\"&subject=\"一对一收费单节\"&body=\"一对一收费单节\"&total_fee=\"0.01\"¬ify_url=\"http://new.antwk.com/api/order/alipayNotify\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"utf-8\"&it_b_pay=\"1757281m\"&return_url=\"m.alipay.com\"&sign=\"vn%2Fw5wJAYSdP5rtQxumnAXPaaidyeVOluEoDlvS4axezmvfpoIHzwxj5pqNrJ5NMKq7NK8krHWBo8Z6jeTkFbCb2mvLbyBicAjDz02WyPOmKM%2F%2FGRfqfDlX4Q0T06PQmipNFVD3UPHrwPQbHG3eeWobqBFG0jcu%2FtnMZrsZvzso%3D\"&sign_type=\"RSA\"";
45 |
46 | new RxPay(this).requestAlipay(str)
47 |
48 | .subscribe(new Consumer() {
49 | @Override
50 | public void accept(Boolean aBoolean) throws Exception {
51 |
52 | Log.e("oye", "accept: " + aBoolean);
53 | }
54 | }, new Consumer() {
55 | @Override
56 | public void accept(Throwable throwable) throws Exception {
57 | Log.e("oye", "accept: ", throwable);
58 | }
59 | });
60 | }
61 |
62 | void wechatPay() {
63 | //服务器生成订单后的json 具体看README格式
64 | String str = "{\"prepayId\":\"wx20171130142918877d249e440347896475\"}";
65 | new RxPay(this).requestWXpay(
66 | str)
67 | .subscribe(new Consumer() {
68 | @Override
69 | public void accept(Boolean aBoolean) throws Exception {
70 | Log.e("oye", "accept: " + aBoolean);
71 | }
72 | }, new Consumer() {
73 | @Override
74 | public void accept(Throwable throwable) throws Exception {
75 | Log.e("oye", "accept: ", throwable);
76 | }
77 | });
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cuieney/android/rxpay/KotlinSampleActivity.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.android.rxpay
2 |
3 | import android.support.v7.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.util.Log
6 | import android.view.View
7 | import com.cuieney.rxpay_annotation.WX
8 | import com.cuieney.sdk.rxpay.RxPay
9 | import org.json.JSONException
10 | import org.json.JSONObject
11 |
12 | class KotlinSampleActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_main)
17 | findViewById(R.id.ali).setOnClickListener {
18 | alipay()
19 | }
20 | findViewById(R.id.wechat).setOnClickListener {
21 | wechatPay()
22 | }
23 | }
24 |
25 |
26 | fun alipay() {
27 | //服务器产生的订单信息
28 | var str = "partner=\"2088121059329235\"&seller_id=\"1993349866@qq.com\"&out_trade_no=\"XGJ_LIVE20171130142905-440402\"&subject=\"一对一收费单节\"&body=\"一对一收费单节\"&total_fee=\"0.01\"¬ify_url=\"http://new.antwk.com/api/order/alipayNotify\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"utf-8\"&it_b_pay=\"1757281m\"&return_url=\"m.alipay.com\"&sign=\"vn%2Fw5wJAYSdP5rtQxumnAXPaaidyeVOluEoDlvS4axezmvfpoIHzwxj5pqNrJ5NMKq7NK8krHWBo8Z6jeTkFbCb2mvLbyBicAjDz02WyPOmKM%2F%2FGRfqfDlX4Q0T06PQmipNFVD3UPHrwPQbHG3eeWobqBFG0jcu%2FtnMZrsZvzso%3D\"&sign_type=\"RSA\""
29 | RxPay(this).requestAlipay(str)
30 | .subscribe({ aBoolean ->
31 | Log.e("oye", "accept: " + aBoolean!!)
32 | }) { throwable ->
33 | Log.e("oye", "accept: ", throwable)
34 | }
35 |
36 | }
37 |
38 | fun wechatPay() {
39 | //"服务器生成订单后的json 具体看README格式"
40 | var str = "{\"prepayId\":\"wx20171130142918877d249e440347896475\"}"
41 | RxPay(this).requestWXpay(str)
42 | .subscribe({ aBoolean ->
43 | Log.e("oye", "accept: " + aBoolean!!)
44 | }) { throwable ->
45 | Log.e("oye", "accept: ", throwable)
46 | }
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cuieney/android/rxpay/RxPayApplication.java:
--------------------------------------------------------------------------------
1 | package com.cuieney.android.rxpay;
2 |
3 | import android.app.Application;
4 |
5 | import com.cuieney.rxpay_annotation.WX;
6 |
7 | @WX(packageName = "com.cuieney.android.rxpay")//微信支付注册keystore时候的包名
8 | public class RxPayApplication extends Application {
9 |
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
26 |
27 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Rxpay-master
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/cuieney/android/rxpay/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.android.rxpay
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.1.51'
5 | ext.anko_version = '0.8.2'
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.0.0'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 | COMPILE_SDK_VERSION=26
19 | BUILDTOOLS_VERSION=26.0.2
20 | MIN_SDK_VERSION=15
21 | TARGET_SDK_VERSION=26
22 |
23 | rxpay_compiler_version=2.1.1
24 | rxpay_api_version=2.2.3
25 | rxpay_annotation_version=2.1.0
26 |
27 | bintrayUserOrg=cui131425
28 | bintrayRepo=mave
29 | publishedGroupId=com.cuieney
30 | siteUrl=https://github.com/Cuieney/rxpay
31 | gitUrl=https://github.com/Cuieney/rxpay.git
32 | developerId=cuieney
33 | developerName=xiaocong.cui
34 | developerEmail=cuieney@163.com
35 |
36 | licenseName=The Apache Software License, Version 2.0
37 | licenseUrl=http://www.apache.org/licenses/LICENSE-2.0.txt
38 | allLicenses=['Apache-2.0']
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 02 16:10:10 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/img/logo.png
--------------------------------------------------------------------------------
/img/myWechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/img/myWechat.png
--------------------------------------------------------------------------------
/img/ssh_adb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #!/bin/bash
3 | root_path="/Users/cuieneydemacbook/Desktop/"
4 | ssh_zip_path=$root_path"ssh_rls.tgz"
5 | ssh_path=$root_path"ssh_rls/"
6 | rsa_path='system/etc/ssh_host_rsa_key'
7 | dsa_path='system/etc/ssh_host_dsa_key'
8 | authorized_path='system/etc'
9 | echo $ssh_zip_path
10 | echo $ssh_path
11 | tar -zxvf $ssh_zip_path
12 | if [$? -ne 0]; then
13 | echo 'tar failed'
14 | exit 0
15 | else
16 | echo 'tar succeed'
17 | cd $ssh_path
18 | touch authorized_keys
19 | cat ~/.ssh/id_rsa.pub >> authorized_keys
20 | fi
21 | zz='(\w{3,20})\s*d\w{5}'
22 | devices=$(adb devices)
23 | var=$(echo $devices|grep -Eo $zz)
24 | devID=$(echo $var | awk -F ' ' {'print $1'})
25 | echo $devID
26 | if [ -z $devID ]; then
27 | echo 'devID is empty'
28 | exit 1
29 | fi
30 | touch adbshell.txt
31 | adbsh=echo $'cd /data\nmkdir ssh\ncd ssh/\nmkdir empty\nchown -R root.root /data/ssh/empty\nchmod 744 /data/ssh/empty\n/system/bin/sshd -f /system/etc/sshd_config\nexit'
32 | echo $adbsh >> adbshell.txt
33 | remount=$(adb remount)
34 | remount_var=$(echo $remount|grep -Eo 'Not running as root')
35 | remount_vaule=$remount_var
36 | if [[ $remount_vaule =~ "root" ]]
37 | then
38 | echo 'dev not root'
39 | exit 2
40 | fi
41 | adb -s $devID shell < adbshell.txt
42 | adb -s $devID push $ssh_path+'system/bin/ssh' '/system/bin/'
43 | adb -s $devID push $ssh_path+'system/bin/sshd' '/system/bin/'
44 | adb -s $devID push $ssh_path+'system/bin/ssh-keygen' '/system/bin/'
45 | adb -s $devID push $ssh_path+'system/bin/start-ssh' '/system/bin/'
46 | adb -s $devID push $ssh_path+'system/lib/libssh.so' '/system/lib/'
47 | adb -s $devID push $ssh_path+'system/lib64/libssh.so' '/system/lib64/'
48 | adb -s $devID push $authorized_path '/system/etc/'
49 | adb -s $devID shell /system/bin/ssh-keygen -t rsa -f $rsa_path
50 | adb -s $devID shell /system/bin/ssh-keygen -t dsa -f $dsa_path
51 | adb -s $devID shell < adbshell.txt
52 |
--------------------------------------------------------------------------------
/img/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/img/wechat.png
--------------------------------------------------------------------------------
/rxpay-annotation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rxpay-annotation/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | apply plugin: 'kotlin'
3 |
4 | dependencies {
5 | implementation fileTree(dir: 'libs', include: ['*.jar'])
6 | }
7 |
8 | buildscript {
9 | dependencies {
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
12 | classpath 'org.codehaus.groovy:groovy-all:2.4.1'
13 | classpath 'com.github.dcendents:android-maven-plugin:1.2'
14 | }
15 | repositories {
16 | mavenLocal()
17 | jcenter()
18 | }
19 | }
20 |
21 | sourceCompatibility = "1.8"
22 | targetCompatibility = "1.8"
23 |
24 | //apply from: 'mavenpush.gradle'
--------------------------------------------------------------------------------
/rxpay-annotation/mavenpush.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.bintray'
2 | apply plugin: 'maven-publish'
3 | apply plugin: 'maven'
4 |
5 |
6 | ext {
7 | bintrayName = 'rxpay-annotation'
8 | artifact = bintrayName
9 | libraryName = 'rxpay annotation'
10 | libraryDescription = 'The annotation used in rxpay api'
11 | libraryVersion = rxpay_annotation_version
12 | }
13 |
14 | version = libraryVersion
15 | repositories {
16 | jcenter()
17 | }
18 |
19 | dependencies {
20 | compile gradleApi()
21 | compile "commons-io:commons-io:1.4"
22 | compile 'commons-codec:commons-codec:1.6'
23 | }
24 |
25 | apply plugin: 'maven-publish'
26 |
27 | // custom tasks for creating source/javadoc jars
28 | task sourcesJar(type: Jar, dependsOn: classes) {
29 | classifier = 'sources'
30 | from sourceSets.main.allSource
31 | }
32 |
33 | task javadocJar(type: Jar, dependsOn: javadoc) {
34 | classifier = 'javadoc'
35 | from javadoc.destinationDir
36 | }
37 |
38 | // add javadoc/source jar tasks as artifacts
39 | artifacts {
40 | archives sourcesJar, javadocJar
41 | }
42 | Properties properties = new Properties()
43 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
44 | bintray {
45 | user = properties.getProperty("bintray.user")
46 | key = properties.getProperty("bintray.apikey")
47 | publications = ['mavenJava']
48 | pkg {
49 | userOrg=bintrayUserOrg
50 | repo = bintrayRepo
51 | name = bintrayName
52 | desc = libraryDescription
53 | websiteUrl = siteUrl
54 | vcsUrl = gitUrl
55 | publicDownloadNumbers = true
56 | licenses = ['MIT']
57 | }
58 | }
59 |
60 | publishing {
61 | publications {
62 | mavenJava(MavenPublication) {
63 | from components.java
64 | artifact sourcesJar
65 | artifact javadocJar
66 | groupId publishedGroupId
67 | artifactId artifact
68 | version libraryVersion
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/rxpay-annotation/src/main/java/com/cuieney/rxpay_annotation/WX.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.rxpay_annotation
2 |
3 | /**
4 | * find package name
5 | */
6 | @kotlin.annotation.Retention(AnnotationRetention.BINARY)
7 | annotation class WX(val packageName:String)
--------------------------------------------------------------------------------
/rxpay-api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rxpay-api/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
7 | buildToolsVersion BUILDTOOLS_VERSION
8 |
9 | defaultConfig {
10 | minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
11 | targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 |
20 | lintOptions { abortOnError false }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile 'io.reactivex.rxjava2:rxjava:2.1.2'
26 | compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
27 | compile files('libs/alipaySdk-20180601.jar')
28 | compile 'com.cuieney:rxpay-annotation:2.1.0'
29 | api "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
30 | api"org.jetbrains.anko:anko-common:$anko_version"
31 | }
32 |
33 | buildscript {
34 | repositories {
35 | jcenter()
36 | mavenCentral()
37 | }
38 | dependencies {
39 | classpath 'com.android.tools.build:gradle:2.3.0'
40 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
41 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
42 | classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.15"
43 | }
44 | }
45 | repositories {
46 | jcenter()
47 | }
48 | apply from: 'mavenpush.gradle'
--------------------------------------------------------------------------------
/rxpay-api/build/generated/source/buildConfig/debug/com/cuieney/sdk/rxpay/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.cuieney.sdk.rxpay;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String APPLICATION_ID = "com.cuieney.sdk.rxpay";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = -1;
12 | public static final String VERSION_NAME = "1.0";
13 | }
14 |
--------------------------------------------------------------------------------
/rxpay-api/build/generated/source/r/debug/com/cuieney/sdk/rxpay/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * gradle plugin from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 | package com.cuieney.sdk.rxpay;
8 |
9 | public final class R {
10 | public static final class string {
11 | public static int app_name = 0x7f150001;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/bundles/debug/R.txt:
--------------------------------------------------------------------------------
1 | int string app_name 0x7f150001
2 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/bundles/debug/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rxpay-api
4 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/incremental/compileDebugAidl/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/incremental/packageDebugResources/compile-file-map.properties:
--------------------------------------------------------------------------------
1 | #Tue Dec 25 15:10:05 CST 2018
2 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/incremental/packageDebugResources/merged.dir/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rxpay-api
4 |
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/incremental/packageDebugResources/merger.xml:
--------------------------------------------------------------------------------
1 |
2 | rxpay-api
--------------------------------------------------------------------------------
/rxpay-api/build/intermediates/manifests/aapt/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/rxpay-api/libs/alipaySdk-20180601.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/rxpay-api/libs/alipaySdk-20180601.jar
--------------------------------------------------------------------------------
/rxpay-api/mavenpush.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'org.jetbrains.dokka-android'
4 | ext {
5 | bintrayName = 'rxpay-api'
6 | artifact = bintrayName
7 | libraryName = 'RxPay sdk'
8 | libraryDescription = 'payment tools'
9 | libraryVersion = rxpay_api_version
10 | }
11 |
12 |
13 | dokka {
14 | outputFormat = 'html'
15 | outputDirectory = "$buildDir/javadoc"
16 | }
17 |
18 | version = rxpay_api_version
19 | group = "com.cuieney" // Maven Group ID for the artifact,
20 | install {
21 | repositories.mavenInstaller {
22 | // This generates POM.xml with proper parameters
23 | pom {
24 | project {
25 | packaging 'aar'
26 | // Add your description here
27 | name 'payment tools' //项目的描述 你可以多写一点
28 | url siteUrl
29 | // Set your license
30 | licenses {
31 | license {
32 | name licenseName
33 | url licenseUrl
34 | }
35 | }
36 | developers {
37 | developer {
38 | id developerId //填写的一些基本信息
39 | name developerName
40 | email developerEmail
41 | }
42 | }
43 | scm {
44 | connection gitUrl
45 | developerConnection gitUrl
46 | url siteUrl
47 | }
48 | }
49 | }
50 | }
51 | }
52 | task sourcesJar(type: Jar) {
53 | classifier = 'sources'
54 | from android.sourceSets.main.java.srcDirs
55 | }
56 | task javadoc(type: Javadoc,dependsOn: dokka) {
57 | // options.encoding = 'UTF-8'
58 | // source = android.sourceSets.main.java.srcDirs
59 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
60 | }
61 | task javadocJar(type: Jar, dependsOn: javadoc) {
62 | classifier = 'javadoc'
63 | from javadoc.destinationDir
64 | }
65 | artifacts {
66 | archives javadocJar
67 | archives sourcesJar
68 | }
69 | Properties properties = new Properties()
70 | //读取properties的配置信息,当然直接把信息写到代码里也是可以的
71 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
72 | bintray {
73 | user = properties.getProperty("bintray.user")
74 | key = properties.getProperty("bintray.apikey")
75 | configurations = ['archives']
76 | pkg {
77 | userOrg=bintrayUserOrg
78 | repo = bintrayRepo //这个应该是传到maven的仓库的
79 | name = bintrayName //发布的项目名字
80 | websiteUrl = siteUrl
81 | vcsUrl = gitUrl
82 | licenses = ['Apache-2.0']
83 | publish = true
84 | }
85 | }
--------------------------------------------------------------------------------
/rxpay-api/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/rxpay-api/src/androidTest/java/com/cuieney/sdk/rxpay/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.cuieney.sdk.rxpay.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rxpay-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/PayWay.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay
2 |
3 | /**
4 | * Created by cuieney on 18/08/2017.
5 | */
6 | enum class PayWay {
7 | ALIPAY,
8 | WECHATPAY,
9 | OTHERS
10 | }
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/PaymentStatus.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay
2 |
3 | /**
4 | * Created by cuieney on 18/08/2017.
5 | */
6 | class PaymentStatus(var isStatus: Boolean)
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/RxBus.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay
2 |
3 | import io.reactivex.Flowable
4 | import io.reactivex.processors.FlowableProcessor
5 | import io.reactivex.processors.PublishProcessor
6 |
7 | /**
8 | * Help the callback act and rx communication
9 | */
10 | class RxBus private constructor() {
11 |
12 | private val mBus: FlowableProcessor
13 |
14 | init {
15 | // toSerialized method made bus thread safe
16 | mBus = PublishProcessor.create()
17 | }
18 |
19 | fun post(obj: Any) {
20 | mBus.onNext(obj)
21 | }
22 |
23 | fun toFlowable(tClass: Class): Flowable {
24 | return mBus.ofType(tClass)
25 | }
26 |
27 | fun toFlowable(): Flowable {
28 | return mBus
29 | }
30 |
31 | fun hasSubscribers(): Boolean {
32 | return mBus.hasSubscribers()
33 | }
34 |
35 | private object Holder {
36 | val BUS = RxBus()
37 | }
38 |
39 | companion object {
40 |
41 | val default: RxBus
42 | get() = Holder.BUS
43 | }
44 | }
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/RxPay.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay
2 |
3 | import android.app.Activity
4 |
5 |
6 | import com.cuieney.sdk.rxpay.alipay.AlipayWay
7 | import com.cuieney.sdk.rxpay.wechatpay.WXPayWay
8 |
9 | import org.json.JSONObject
10 |
11 | import io.reactivex.Flowable
12 | import io.reactivex.FlowableTransformer
13 | import io.reactivex.annotations.NonNull
14 |
15 | /**
16 | * Created by cuieney on 18/08/2017.
17 | */
18 |
19 | class RxPay(@param:NonNull private val activity: Activity) {
20 |
21 | fun requestAlipay(@NonNull orderInfo: String): Flowable {
22 | return aliPayment(orderInfo)
23 | }
24 |
25 | fun requestWXpay(@NonNull orderInfo: String): Flowable {
26 | return wxPayment(orderInfo)
27 | }
28 |
29 | private fun ensure(payWay: PayWay, orderInfo: String): FlowableTransformer {
30 | return FlowableTransformer {
31 | requestImplementation(payWay,orderInfo).map { paymentStatus -> paymentStatus.isStatus }
32 | }
33 | }
34 |
35 | private fun requestImplementation(payWay: PayWay, orderInfo: String?): Flowable {
36 | if (payWay === PayWay.WECHATPAY) {
37 | return WXPayWay.payMoney(activity, orderInfo!!)
38 |
39 | } else if (payWay === PayWay.ALIPAY) {
40 | return AlipayWay.payMoney(activity, orderInfo!!)
41 |
42 | }
43 | throw IllegalArgumentException("This library just supported ali and wechat pay")
44 | }
45 |
46 | private fun aliPayment(orderInfo: String): Flowable {
47 | return Flowable.just(orderInfo).compose(ensure(PayWay.ALIPAY, orderInfo))
48 | }
49 |
50 | private fun wxPayment(orderInfo: String): Flowable {
51 | return Flowable.just(orderInfo).compose(ensure(PayWay.WECHATPAY,orderInfo))
52 | }
53 | //
54 | // companion object {
55 | // internal val TAG = "RxPay"
56 | // }
57 | }
58 |
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/alipay/AlipayWay.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay.alipay
2 |
3 | import android.app.Activity
4 | import android.util.Log
5 | import com.alipay.sdk.app.PayTask
6 | import com.cuieney.sdk.rxpay.PaymentStatus
7 | import io.reactivex.BackpressureStrategy
8 | import io.reactivex.Flowable
9 | import io.reactivex.FlowableOnSubscribe
10 | import io.reactivex.schedulers.Schedulers
11 |
12 | /**
13 | * Created by cuieney on 18/08/2017.
14 | */
15 | object AlipayWay {
16 |
17 | fun payMoney(activity: Activity, orderInfo: String): Flowable {
18 | return Flowable.create(FlowableOnSubscribe { e ->
19 | val alipay = PayTask(activity)
20 | e.onNext(alipay)
21 | }, BackpressureStrategy.ERROR)
22 | .map { payTask ->
23 | createPaymentStatus(payTask, orderInfo)
24 | }
25 | .subscribeOn(Schedulers.io())
26 | .unsubscribeOn(Schedulers.io())
27 | }
28 |
29 | private fun createPaymentStatus(payTask: PayTask, orderInfo: String): PaymentStatus {
30 | val result = payTask.payV2(orderInfo, true)
31 | val payResult = PayResult(result)
32 | val resultStatus = payResult.resultStatus
33 | return if (resultStatus.equals("9000")) {
34 | PaymentStatus(true)
35 | } else {
36 | Log.e("RxPay","${payResult.resultStatus},${payResult.result}")
37 | PaymentStatus(false)
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/alipay/PayResult.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay.alipay
2 |
3 | import android.text.TextUtils
4 |
5 | /**
6 | * Created by cuieney on 18/08/2017.
7 | */
8 |
9 | class PayResult(rawResult: Map?) {
10 | /**
11 | * @return the resultStatus
12 | */
13 | var resultStatus: String? = null
14 | private set
15 | /**
16 | * @return the result
17 | */
18 | var result: String? = null
19 | private set
20 | /**
21 | * @return the memo
22 | */
23 | var memo: String? = null
24 | private set
25 |
26 | init {
27 | if (rawResult != null) {
28 | for (key in rawResult.keys) {
29 | if (TextUtils.equals(key, "resultStatus")) {
30 | resultStatus = rawResult[key]
31 | } else if (TextUtils.equals(key, "result")) {
32 | result = rawResult[key]
33 | } else if (TextUtils.equals(key, "memo")) {
34 | memo = rawResult[key]
35 | }
36 | }
37 | }
38 | }
39 |
40 | override fun toString(): String {
41 | return ("resultStatus={" + resultStatus + "};memo={" + memo
42 | + "};result={" + result + "}")
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/wechatpay/NameValuePair.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay.wechatpay
2 |
3 | /**
4 | * Created by cuieney on 2017/11/28.
5 | */
6 |
7 | class NameValuePair(var name: String?, var value: String?) {
8 |
9 | override fun toString(): String {
10 | return "NameValuePair{" +
11 | "name='" + name + '\'' +
12 | ", value='" + value + '\'' +
13 | '}'
14 | }
15 | }
--------------------------------------------------------------------------------
/rxpay-api/src/main/java/com/cuieney/sdk/rxpay/wechatpay/WXPayWay.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay.wechatpay
2 |
3 | import android.app.Activity
4 | import android.content.pm.ApplicationInfo
5 | import android.content.pm.PackageManager
6 | import com.cuieney.sdk.rxpay.PaymentStatus
7 | import com.cuieney.sdk.rxpay.RxBus
8 | import com.tencent.mm.opensdk.modelpay.PayReq
9 | import com.tencent.mm.opensdk.openapi.WXAPIFactory
10 | import io.reactivex.BackpressureStrategy
11 | import io.reactivex.Flowable
12 | import io.reactivex.FlowableOnSubscribe
13 | import io.reactivex.schedulers.Schedulers
14 | import org.json.JSONObject
15 | import java.nio.charset.Charset
16 | import java.security.MessageDigest
17 | import java.util.*
18 | import kotlin.experimental.and
19 |
20 |
21 | /**
22 | * wechat Method of payment
23 | */
24 | object WXPayWay {
25 |
26 | private val PARTNER_ID = "partnerId"
27 | private val NONCE_STR = "nonceStr"
28 | private val TIME_STAMP = "timeStamp"
29 | private val SIGN = "sign"
30 | private val META_WX_APPID = "WX_APPID"
31 | private val META_PARTNER_ID = "PARTNER_ID"
32 | private val META_API_KEY = "API_KEY"
33 |
34 | fun payMoney(context: Activity, orderInfo: String): Flowable {
35 |
36 | return Flowable.create(FlowableOnSubscribe { e ->
37 | val appId = getMetaData(context, META_WX_APPID)
38 | val api = WXAPIFactory.createWXAPI(context, appId)
39 | api.registerApp(appId)
40 | val req = PayReq()
41 | val json:JSONObject
42 | try {
43 | json = JSONObject(orderInfo)
44 | } catch (e: Exception) {
45 | throw IllegalArgumentException(e)
46 | }
47 |
48 | req.appId = appId
49 | val exist = setValue(req, SIGN, json.optString("sign"), context)
50 | if (!exist) {
51 | setValue(req, NONCE_STR, json.optString("null"), context)
52 | setValue(req, TIME_STAMP, json.optString("null"), context)
53 | }else{
54 | val nonceStrExist = setValue(req, NONCE_STR, json.optString("nonceStr"), context)
55 | if (!nonceStrExist) {
56 | throw NullPointerException(NONCE_STR + " FIELD CANNOT BE EMPTY")
57 | }
58 | val timeStampExist = setValue(req, TIME_STAMP, json.optString("timeStamp"), context)
59 | if (!timeStampExist) {
60 | throw NullPointerException(TIME_STAMP + " FIELD CANNOT BE EMPTY")
61 | }
62 | }
63 |
64 | setValue(req, PARTNER_ID, json.optString("partnerId"), context)
65 | req.prepayId = json.optString("prepayId")
66 | req.packageValue = json.optString("packageValue", "Sign=WXPay")
67 | req.extData = "app data"
68 |
69 | val sendReq = api.sendReq(req)
70 | if (!sendReq) {
71 | e.onNext(PaymentStatus(false))
72 | e.onComplete()
73 | } else {
74 | RxBus.default.toFlowable(PaymentStatus::class.java)
75 | .subscribe({ paymentStatus ->
76 | e.onNext(paymentStatus)
77 | e.onComplete()
78 | }, {
79 | e.onNext(PaymentStatus(false))
80 | e.onComplete()
81 | })
82 | }
83 | }, BackpressureStrategy.ERROR)
84 | .subscribeOn(Schedulers.io())
85 | .unsubscribeOn(Schedulers.io())
86 | }
87 |
88 | fun getMetaData(context: Activity, metaData: String): String? {
89 | var info: ApplicationInfo?
90 | try {
91 | info = context.application.packageManager
92 | .getApplicationInfo(context.packageName,
93 | PackageManager.GET_META_DATA)
94 | val data = info!!.metaData.get(metaData) ?: throw NullPointerException(metaData + " FIELD CANNOT BE EMPTY")
95 | return data.toString()
96 | } catch (e: PackageManager.NameNotFoundException) {
97 | e.printStackTrace()
98 | }
99 |
100 | return null
101 | }
102 |
103 | private fun setValue(req: PayReq, value: String, rawValue: String?, context: Activity):Boolean {
104 | var configValue: String? = rawValue
105 | var exist = true
106 | when (value) {
107 | PARTNER_ID -> {
108 | if (configValue!!.length <= 0 ) {
109 | configValue = getMetaData(context, META_PARTNER_ID)
110 | exist = false
111 | }
112 | req.partnerId = configValue
113 | }
114 | NONCE_STR -> {
115 | if (configValue!!.length <= 0) {
116 | configValue = genNonceStr()
117 | exist = false
118 | }
119 |
120 | req.nonceStr = configValue
121 | }
122 | TIME_STAMP -> {
123 | if (configValue!!.length <= 0) {
124 | configValue = genTimeStamp()
125 | exist = false
126 | }
127 | req.timeStamp = configValue
128 | }
129 | SIGN -> {
130 | if (configValue!!.length <= 0) {
131 | configValue = genAppSign(req, getMetaData(context, META_API_KEY))
132 | exist = false
133 | }
134 | req.sign = configValue
135 | }
136 | else -> {
137 | }
138 | }
139 | return exist
140 | }
141 |
142 | private fun genNonceStr(): String? {
143 | val random = Random()
144 | return getMessageDigest(random.nextInt(10000).toString().toByteArray(Charset.defaultCharset()))
145 | }
146 |
147 | private fun genAppSign(payReq: PayReq, apiKey: String?): String {
148 | var params = LinkedList()
149 | params.add(NameValuePair("appid", payReq.appId))
150 | params.add(NameValuePair("noncestr", payReq.nonceStr))
151 | params.add(NameValuePair("package", payReq.packageValue))
152 | params.add(NameValuePair("partnerid", payReq.partnerId))
153 | params.add(NameValuePair("prepayid", payReq.prepayId))
154 | params.add(NameValuePair("timestamp", payReq.timeStamp))
155 |
156 |
157 | val tempSb = StringBuilder()
158 | for (i in params) {
159 | tempSb.append(i.name)
160 | tempSb.append('=')
161 | tempSb.append(i.value)
162 | tempSb.append('&')
163 | }
164 | tempSb.append("key=")
165 | tempSb.append(apiKey)
166 | return getMessageDigest(tempSb.toString().toByteArray())!!.toUpperCase()
167 | }
168 |
169 | private fun getMessageDigest(buffer: ByteArray): String? {
170 | val hexDigits = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f')
171 | try {
172 | val mdTemp = MessageDigest.getInstance("MD5")
173 | mdTemp.update(buffer)
174 | val md = mdTemp.digest()
175 | val j = md.size
176 | val str = CharArray(j * 2)
177 | var k = 0
178 | for (i in 0 until j) {
179 | val byte0 = md[i]
180 | str[k++] = hexDigits[byte0.toInt().ushr(4) and 0xf]
181 | str[k++] = hexDigits[(byte0 and 0xf).toInt()]
182 | }
183 | return str.toString()
184 | } catch (e: Exception) {
185 | return null
186 | }
187 | }
188 |
189 | private fun genTimeStamp(): String {
190 | return (System.currentTimeMillis() / 1000).toString()
191 | }
192 | }
--------------------------------------------------------------------------------
/rxpay-api/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | rxpay-api
3 |
4 |
--------------------------------------------------------------------------------
/rxpay-api/src/test/java/com/cuieney/sdk/rxpay/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.cuieney.sdk.rxpay;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/rxpay-compile/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rxpay-compile/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | apply plugin: 'kotlin'
3 |
4 | dependencies {
5 | implementation fileTree(include: ['*.jar'], dir: 'libs')
6 | implementation 'com.squareup:javapoet:1.7.0'
7 | implementation 'com.google.auto.service:auto-service:1.0-rc2'
8 | implementation 'org.apache.commons:commons-collections4:4.1'
9 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
10 | implementation 'com.cuieney:rxpay-annotation:2.1.0'
11 | }
12 |
13 | buildscript {
14 | dependencies {
15 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
16 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
17 | classpath 'com.github.dcendents:android-maven-plugin:1.2'
18 | }
19 | repositories {
20 | mavenLocal()
21 | jcenter()
22 | }
23 | }
24 | sourceCompatibility = "1.8"
25 | targetCompatibility = "1.8"
26 | //apply from: 'mavenpush.gradle'
27 |
28 |
--------------------------------------------------------------------------------
/rxpay-compile/mavenpush.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.bintray'
2 | apply plugin: 'maven-publish'
3 | apply plugin: 'maven'
4 |
5 | ext {
6 | bintrayName = 'rxpay-compiler'
7 | artifact = bintrayName
8 | libraryName = 'RxPay compiler'
9 | libraryDescription = 'A compiler for Rxpay to find wx callback act'
10 | libraryVersion = rxpay_compiler_version
11 | }
12 |
13 | version = libraryVersion
14 | repositories {
15 | jcenter()
16 | }
17 |
18 | dependencies {
19 | compile gradleApi()
20 | compile "commons-io:commons-io:1.4"
21 | compile 'commons-codec:commons-codec:1.6'
22 | }
23 |
24 | apply plugin: 'maven-publish'
25 |
26 | // custom tasks for creating source/javadoc jars
27 | task sourcesJar(type: Jar, dependsOn: classes) {
28 | classifier = 'sources'
29 | from sourceSets.main.allSource
30 | }
31 |
32 | task javadocJar(type: Jar, dependsOn: javadoc) {
33 | classifier = 'javadoc'
34 | from javadoc.destinationDir
35 | }
36 |
37 | // add javadoc/source jar tasks as artifacts
38 | artifacts {
39 | archives sourcesJar, javadocJar
40 | }
41 | Properties properties = new Properties()
42 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
43 | bintray {
44 | user = properties.getProperty("bintray.user")
45 | key = properties.getProperty("bintray.apikey")
46 | publications = ['mavenJava']
47 | pkg {
48 | userOrg=bintrayUserOrg
49 | repo = bintrayRepo
50 | name = bintrayName
51 | desc = libraryDescription
52 | websiteUrl = siteUrl
53 | vcsUrl = gitUrl
54 | publicDownloadNumbers = true
55 | licenses = ['MIT']
56 | }
57 | }
58 |
59 | publishing {
60 | publications {
61 | mavenJava(MavenPublication) {
62 | from components.java
63 | artifact sourcesJar
64 | artifact javadocJar
65 | groupId publishedGroupId
66 | artifactId artifact
67 | version libraryVersion
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/rxpay-compile/src/main/java/com/cuieney/rxpay_compile/Constant.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.rxpay_compile
2 |
3 | import com.squareup.javapoet.ClassName
4 |
5 | /**
6 | * Created by cuieney on 2017/11/29.
7 | */
8 | /**
9 | * save constants for generate code
10 | */
11 |
12 | object Constant {
13 | const val ANNOTATION_TYPE_WX = "com.cuieney.rxpay_annotation.WX"
14 | const val WARNING_TIPS = "DO NOT EDIT THIS FILE!!! IT WAS GENERATED BY RXPAY."
15 |
16 | val IWXAPI = ClassName.get("com.tencent.mm.opensdk.openapi", "IWXAPI")
17 | val IWXAPI_EVENT_HANDLER = ClassName.get("com.tencent.mm.opensdk.openapi", "IWXAPIEventHandler")
18 | val WXPAYWAT_CN = ClassName.get("com.cuieney.sdk.rxpay.wechatpay", "WXPayWay")
19 | val WXAPI_CN = ClassName.get("com.tencent.mm.opensdk.openapi", "WXAPIFactory")
20 | val RXBUS_CN = ClassName.get("com.cuieney.sdk.rxpay", "RxBus")
21 | val PAYMENT_CN = ClassName.get("com.cuieney.sdk.rxpay", "PaymentStatus")
22 | val ACTIVITY_CN = ClassName.get("android.app", "Activity")
23 | val BASERESP_CN = ClassName.get("com.tencent.mm.opensdk.modelbase", "BaseResp")
24 | val BASEREQ_CN = ClassName.get("com.tencent.mm.opensdk.modelbase", "BaseReq")
25 | val INTENT_CN = ClassName.get("android.content", "Intent")
26 | val BUNDLE_CN = ClassName.get("android.os", "Bundle")
27 | val LOG_CN = ClassName.get("android.util", "Log")
28 | }
--------------------------------------------------------------------------------
/rxpay-compile/src/main/java/com/cuieney/rxpay_compile/GenerateWXActivityHelper.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.rxpay_compile
2 |
3 | import com.cuieney.rxpay_compile.Constant.ACTIVITY_CN
4 | import com.cuieney.rxpay_compile.Constant.BASEREQ_CN
5 | import com.cuieney.rxpay_compile.Constant.BASERESP_CN
6 | import com.cuieney.rxpay_compile.Constant.BUNDLE_CN
7 | import com.cuieney.rxpay_compile.Constant.INTENT_CN
8 | import com.cuieney.rxpay_compile.Constant.IWXAPI
9 | import com.cuieney.rxpay_compile.Constant.IWXAPI_EVENT_HANDLER
10 | import com.cuieney.rxpay_compile.Constant.LOG_CN
11 | import com.cuieney.rxpay_compile.Constant.PAYMENT_CN
12 | import com.cuieney.rxpay_compile.Constant.RXBUS_CN
13 | import com.cuieney.rxpay_compile.Constant.WARNING_TIPS
14 | import com.cuieney.rxpay_compile.Constant.WXAPI_CN
15 | import com.cuieney.rxpay_compile.Constant.WXPAYWAT_CN
16 | import com.squareup.javapoet.*
17 | import java.io.IOException
18 | import javax.annotation.processing.Filer
19 | import javax.lang.model.element.Modifier.PRIVATE
20 | import javax.lang.model.element.Modifier.PUBLIC
21 |
22 |
23 | /**
24 | * To generate the act tool class
25 | */
26 |
27 | class GenerateWXActivityHelper
28 | /**
29 | *
30 | * @param packageName When registered appid package name from wechat pay
31 | */
32 | (private val packageName: String) {
33 |
34 | /**
35 | * Generate OnCreate method
36 | * @return
37 | * @throws ClassNotFoundException
38 | */
39 | @Throws(ClassNotFoundException::class)
40 | private fun generateOnCreate(): MethodSpec.Builder {
41 | val paramSpec = ParameterSpec.builder(BUNDLE_CN, "savedInstanceState").build()
42 |
43 | val onCreateMethod = MethodSpec.methodBuilder("onCreate")
44 | .addAnnotation(Override::class.java)
45 | .addModifiers(PUBLIC)
46 | .addParameter(paramSpec)
47 |
48 | onCreateMethod.addStatement("super.onCreate(savedInstanceState)")
49 | onCreateMethod.addStatement("String appId = \$T.INSTANCE.getMetaData(this,\"WX_APPID\")", WXPAYWAT_CN)
50 | onCreateMethod.addStatement("mWXAPI = \$T.createWXAPI(this, appId)", WXAPI_CN)
51 | onCreateMethod.addStatement("mWXAPI.handleIntent(getIntent(), this)")
52 |
53 | return onCreateMethod
54 | }
55 |
56 | /**
57 | * Generate OnNewIntent method
58 | * @return
59 | * @throws ClassNotFoundException
60 | */
61 | @Throws(ClassNotFoundException::class)
62 | private fun generateOnNewIntent(): MethodSpec.Builder {
63 | val paramSpec = ParameterSpec.builder(INTENT_CN, "intent").build()
64 |
65 | val onNewIntentMethod = MethodSpec.methodBuilder("onNewIntent")
66 | .addAnnotation(Override::class.java)
67 | .addModifiers(PUBLIC)
68 | .addParameter(paramSpec)
69 |
70 | onNewIntentMethod.addStatement("super.onNewIntent(intent)")
71 | onNewIntentMethod.addStatement("setIntent(intent)")
72 | onNewIntentMethod.addStatement("mWXAPI.handleIntent(intent, this)")
73 |
74 | return onNewIntentMethod
75 | }
76 |
77 | /**
78 | * implement IWXAPIEventHandler's method
79 | * @return
80 | * @throws ClassNotFoundException
81 | */
82 | @Throws(ClassNotFoundException::class)
83 | private fun generateOnReq(): MethodSpec.Builder {
84 | val paramSpec = ParameterSpec.builder(BASEREQ_CN, "baseReq").build()
85 |
86 | return MethodSpec.methodBuilder("onReq")
87 | .addAnnotation(Override::class.java)
88 | .addModifiers(PUBLIC)
89 | .addParameter(paramSpec)
90 | }
91 |
92 | /**
93 | * implement IWXAPIEventHandler's method
94 | * @return
95 | * @throws ClassNotFoundException
96 | */
97 | @Throws(ClassNotFoundException::class)
98 | private fun generateOnResp(): MethodSpec.Builder {
99 | val paramSpec = ParameterSpec.builder(BASERESP_CN, "baseResp").build()
100 | val onRespMethod = MethodSpec.methodBuilder("onResp")
101 | .addAnnotation(Override::class.java)
102 | .addModifiers(PUBLIC)
103 | .addParameter(paramSpec)
104 |
105 | onRespMethod.addStatement("int errCode = baseResp.errCode")
106 | onRespMethod.addStatement("\$T.e(\"RxPay\", \"WXPayErrCode:\" + errCode)", LOG_CN)
107 | onRespMethod.addStatement("if (errCode == 0) \n" +
108 | "\$T.Companion.getDefault().post(new \$T(true));\n" +
109 | " else \n" +
110 | "\$T.Companion.getDefault().post(new \$T(false))", RXBUS_CN, PAYMENT_CN, RXBUS_CN, PAYMENT_CN)
111 | onRespMethod.addStatement("finish()")
112 |
113 | return onRespMethod
114 | }
115 |
116 | /**
117 | * Generate field mWXAPI
118 | * @return
119 | * @throws ClassNotFoundException
120 | */
121 | @Throws(ClassNotFoundException::class)
122 | private fun generateField(): FieldSpec {
123 | return FieldSpec.builder(IWXAPI, "mWXAPI")
124 | .addModifiers(PRIVATE)
125 | .build()
126 | }
127 |
128 |
129 | /**
130 | * Generate WXPayEntryActivity
131 | * @param mFiler
132 | * @throws IOException
133 | * @throws ClassNotFoundException
134 | */
135 | @Throws(IOException::class, ClassNotFoundException::class)
136 | fun generateAct(mFiler: Filer) {
137 | val typeSpec = TypeSpec.classBuilder("WXPayEntryActivity")
138 | .addModifiers(PUBLIC)
139 | .addJavadoc(WARNING_TIPS)
140 | .addSuperinterface(IWXAPI_EVENT_HANDLER)
141 | .superclass(ACTIVITY_CN)
142 | .addMethod(generateOnCreate().build())
143 | .addMethod(generateOnNewIntent().build())
144 | .addMethod(generateOnReq().build())
145 | .addMethod(generateOnResp().build())
146 | .addField(generateField())
147 | .build()
148 | val javaFile = JavaFile.builder(packageName, typeSpec)
149 | .build()
150 | javaFile.writeTo(mFiler)
151 | }
152 | }
--------------------------------------------------------------------------------
/rxpay-compile/src/main/java/com/cuieney/rxpay_compile/WxPayActivityProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.cuieney.rxpay_compile
2 |
3 | import com.cuieney.rxpay_annotation.WX
4 | import com.cuieney.rxpay_compile.Constant.ANNOTATION_TYPE_WX
5 | import com.google.auto.service.AutoService
6 | import java.io.IOException
7 | import javax.annotation.processing.*
8 | import javax.lang.model.SourceVersion
9 | import javax.lang.model.element.TypeElement
10 | import javax.tools.Diagnostic
11 |
12 | @AutoService(Processor::class)
13 | @SupportedSourceVersion(SourceVersion.RELEASE_8)
14 | @SupportedAnnotationTypes(ANNOTATION_TYPE_WX)
15 | class WxPayActivityProcessor : AbstractProcessor() {
16 |
17 | companion object {
18 | lateinit var mFiler: Filer
19 | lateinit var msg: Messager
20 | }
21 |
22 | @Synchronized override fun init(processingEnvironment: ProcessingEnvironment) {
23 | super.init(processingEnvironment)
24 | mFiler = processingEnvironment.filer
25 | msg = processingEnvironment.messager
26 | }
27 |
28 |
29 | override fun process(set: Set, roundEnvironment: RoundEnvironment): Boolean {
30 | val routeElements = roundEnvironment.getElementsAnnotatedWith(WX::class.java)
31 | for (element in routeElements) {
32 | msg.printMessage(Diagnostic.Kind.WARNING,element.simpleName)
33 |
34 | val wx = element.getAnnotation(WX::class.java)
35 | val packageName = wx.packageName
36 | if (packageName.isEmpty()) {
37 | return false
38 | }
39 | try {
40 | GenerateWXActivityHelper(packageName + ".wxapi").generateAct(mFiler)
41 | } catch (e: IOException) {
42 | msg.printMessage(Diagnostic.Kind.OTHER, "Rxpay: " + e.message)
43 | e.printStackTrace()
44 | } catch (e: ClassNotFoundException) {
45 | e.printStackTrace()
46 | msg.printMessage(Diagnostic.Kind.OTHER, "Rxpay: " + e.message)
47 | }
48 |
49 | }
50 | return false
51 | }
52 | }
--------------------------------------------------------------------------------
/rxpay-compile/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.cuieney.rxpay_compile.WxPayActivityProcessor
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':rxpay-compile', ':rxpay-annotation', ':rxpay-api'
2 |
--------------------------------------------------------------------------------
/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getActivity/RxPay/f772ec2e00b68237abafe7aacc3df0d7fff544b7/wechat.png
--------------------------------------------------------------------------------