Giter VIP home page Giter VIP logo

mobilepaylibrary's Introduction

MobilePayLibrary

针对移动App中常见的第三方支付平台的集成和封装。

针对移动App中常见的第三方支付平台的集成和封装。

微信和支付宝支付库的使用说明

当AAR添加成功之后,接下来还需要操作一下:

支付宝支付

1、导入支付宝需要的权限

2、配置支付宝必须的Activity

3、编译开始使用

--------- AlipayService 使用 -----------

创建对象时参数必须是Activity,由于库中参数要求这样,则意味着必须再界面中调用,或则说必须每个界面重新初始化。 AlipayService service = AlipayService.newInstance(this); service.initPayService(new AlipayInit(Fields.PARTNER,Fields.SELLER, Fields.RSA_PRIVATE)); AlipayProductS product = new AlipayProductS(); service.pay(product);

** 微信支付 **

1、导入微信支付需要的权限

2、配置微信支付必须的WXPayEntryActivity,这个WXPayEntryActivity是自定义但是必须继承WeChatPayHandlerActivity文件,同时实现集中的方法getWeChatAppId和handlePayState,而且这个WXPayEntryActivity必须放入packgage+wxapi目录中。

3、检测微信支付是否安装

MobilePayTool.checkWechatInvalidPay(context, appid),通过返回的boolean来判断是否安装。

4、注意事项

  • 微信的价格是以分为计量单位,不能有小数因为分已经很精确了,所以必须再价格位置传入整数(真实价格*100)转换为分
  • 微信支付的产品信息,一般需要修改价格(Price)、订单号(OutTradeNo)、附件信息(Attach)、回调url(AsynServer)、产品信息(body|Subject)

5、编译开始使用

--------- WeChatPayService 使用 -----------

WeChatPayService service = WeChatPayService.newInstance(this); service.initPayService(new WeChatPayInit(Fields.APP_ID, Fields.MCH_ID, Fields.API_KEY)); service.pay(new WeChatProductS());

4、修改build.gradle

添加: repositories{ flatDir { dirs 'libs' } }

dependencies { compile (name:'MobilePayLibrary', ext:'aar') }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.