RxPay让支付功能从此简单下去

RxPay让支付功能从此简单下去_第1张图片

What's RxPay ?

让支付从此简单下去,一键支付功能,支持支付宝支付,微信支付

项目地址

使用步骤

step 1

Gradle

dependencies {
        compile 'com.cuieney.library:rxpay-api:1.0.3'
        annotationProcessor 'com.cuieney.library:rxpay-compile:1.0.3'
}

step 2

在你的AndroidManifest文件中添加权限

AndroidManifest

    
    
    

step 3

如果你需要用到微信支付的话,请仔细看一下步骤
1.在你要使用微信支付的地方添加一下注解

@WX(packageName = "微信支付注册keystore时候的包名")
public class MainActivity extends AppCompatActivity 

2.在AndroidManifest添加你微信支付的appid

   

3.在AndroidManifest的微信支付回调页面的Activity

     

上面的xxx.xxx.xxx就是你微信支付注册keystore时候的包名,报错没关系,编译会生成对应的Activity。

step 4

发起支付功能

1.发起支付宝支付请求

 rxPay.requestAlipay("服务器产生的订单号")
                .subscribe(new Consumer() {
                    @Override
                    public void accept(Boolean aBoolean) throws Exception {
                        payState.setText("阿里支付状态:"+aBoolean);
                    }
                }, new Consumer() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        payState.setText("阿里支付状态:"+throwable.getMessage());
                    }
                });

2.发起微信支付请求

 rxPay.requestWXpay(new JSONObject(“服务器生成订单的后信息json”))
                .subscribe(new Consumer() {
                    @Override
                    public void accept(Boolean aBoolean) throws Exception {
                        payState.setText("微信支付状态:"+aBoolean);
                    }
                }, new Consumer() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        payState.setText("微信支付状态:"+throwable.getMessage());
                    }
                });

对应的json格式参考

RxPay让支付功能从此简单下去_第2张图片
json.png

code sample

问题

发现bug或好的建议欢迎 issues or
Email [email protected]

License

Copyright 2017 Cuieney

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
``

你可能感兴趣的:(RxPay让支付功能从此简单下去)