Package com.foxinmy.weixin4j.pay
Class PayPackageBuilder
- java.lang.Object
-
- com.foxinmy.weixin4j.pay.PayPackageBuilder
-
public class PayPackageBuilder extends Object
MchPayPackage生成器 微信支付中很多新增的支付产品或功能不定期的在原来各种支付API中添加参数项,导致MchPayPackage类会不断更新 MchPayPackage构造方法参数会越来越多,不断增加的参数项也不好继续改构造方法。 PayApi中一些特定的支付api(如JSAPI、MACROPAY)等都是直接传入参数,然后在API内构造MchPayPackage,而不是传入MchPayPackage, 一旦增加新参数就需要改API,影响正在使用SDK的工程,但如果改为直接使用MchPayPackag的createPayRequest方法, MchPayPackage的构造方式又太难看,开发者需要对着微信文档然后看着构造函数里边一大堆的参数一一匹配 所以最终有了PayPackageBuilder这个类,通过一些链式的API构造MchPayPackage,既提供最小参数的各种支付构造方法,又能让代码看上去直观一些- Author:
- kit (kit.li@qq.com)
-
-
Method Summary
-
-
-
Method Detail
-
init
public static PayPackageBuilder init(MchPayPackage payPackage)
使用MchPayPackage初始化- Parameters:
payPackage
-- Returns:
-
microPay
public static PayPackageBuilder microPay(String body, String outTradeNo, double totalFee, String createIp, String authCode)
付款码支付/人脸支付- Parameters:
body
- 商品描述outTradeNo
- 商户订单号totalFee
- 支付金额createIp
- 终端IPauthCode
- 用户付款码- Returns:
-
jsapiPay
public static PayPackageBuilder jsapiPay(String body, String outTradeNo, double totalFee, String createIp, String notifyUrl, String openid)
JSAPI支付/小程序支付- Parameters:
body
- 商品描述outTradeNo
- 商户订单号totalFee
- 支付金额createIp
- 终端IPnotifyUrl
- 回调通知地址openid
- 用户标识- Returns:
-
nativePay
public static PayPackageBuilder nativePay(String body, String outTradeNo, double totalFee, String createIp, String notifyUrl, String productId)
native支付- Parameters:
body
- 商品描述outTradeNo
- 商户订单号totalFee
- 支付金额createIp
- 终端IPnotifyUrl
- 回调通知地址productId
- 产品ID- Returns:
-
appPay
public static PayPackageBuilder appPay(String body, String outTradeNo, double totalFee, String createIp, String notifyUrl)
APP支付- Parameters:
body
- 商品描述outTradeNo
- 商户订单号totalFee
- 支付金额createIp
- 终端IPnotifyUrl
- 回调通知地址- Returns:
-
h5Pay
public static PayPackageBuilder h5Pay(String body, String outTradeNo, double totalFee, String createIp, String notifyUrl, String wapUrl, String wapName)
H5支付- Parameters:
body
- 商品描述outTradeNo
- 商户订单号totalFee
- 支付金额createIp
- 终端IPnotifyUrl
- 回调通知地址wapUrl
- wap网站URL地址wapName
- wap网站名- Returns:
-
detail
public PayPackageBuilder detail(String detail)
-
attach
public PayPackageBuilder attach(String attach)
-
goodsTag
public PayPackageBuilder goodsTag(String goodsTag)
-
limitPay
public PayPackageBuilder limitPay()
-
timeStart
public PayPackageBuilder timeStart(Date date)
-
timeStart
public PayPackageBuilder timeStart(String date)
-
timeExpire
public PayPackageBuilder timeExpire(Date date)
-
timeExpire
public PayPackageBuilder timeExpire(String date)
-
receipt
public PayPackageBuilder receipt()
-
sceneInfo
public PayPackageBuilder sceneInfo(SceneInfo info)
-
deposit
public PayPackageBuilder deposit()
-
profitSharing
public PayPackageBuilder profitSharing()
-
subOpenId
public PayPackageBuilder subOpenId(String subOpenId)
-
totalFee
public PayPackageBuilder totalFee(double totalFee)
-
totalFee
public PayPackageBuilder totalFee(int totalFee)
-
build
public MchPayPackage build()
-
-