Package com.bytedesk.wechat.pay.sdk
Class WXPay
java.lang.Object
com.bytedesk.wechat.pay.sdk.WXPay
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private WXPayConfig
private String
private WXPayConstants.SignType
private boolean
private WXPayRequest
-
Constructor Summary
ConstructorsConstructorDescriptionWXPay
(WXPayConfig config) WXPay
(WXPayConfig config, boolean autoReport) WXPay
(WXPayConfig config, boolean autoReport, boolean useSandbox) WXPay
(WXPayConfig config, String notifyUrl) WXPay
(WXPayConfig config, String notifyUrl, boolean autoReport) WXPay
(WXPayConfig config, String notifyUrl, boolean autoReport, boolean useSandbox) -
Method Summary
Modifier and TypeMethodDescriptionauthCodeToOpenid
(Map<String, String> reqData) 作用:授权码查询OPENID接口
场景:刷卡支付authCodeToOpenid
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:授权码查询OPENID接口
场景:刷卡支付closeOrder
(Map<String, String> reqData) 作用:关闭订单
场景:公共号支付、扫码支付、APP支付closeOrder
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:关闭订单
场景:公共号支付、扫码支付、APP支付downloadBill
(Map<String, String> reqData) 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)
场景:刷卡支付、公共号支付、扫码支付、APP支付downloadBill
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:对账单下载
场景:刷卡支付、公共号支付、扫码支付、APP支付
其他:无论是否成功都返回Map。fillRequestData
(Map<String, String> reqData) 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign
该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口boolean
isPayResultNotifySignatureValid
(Map<String, String> reqData) 判断支付结果通知中的sign是否有效boolean
isResponseSignatureValid
(Map<String, String> reqData) 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。作用:提交刷卡支付
场景:刷卡支付作用:提交刷卡支付
场景:刷卡支付microPayWithPos
(Map<String, String> reqData) 提交刷卡支付,针对软POS,尽可能做成功 内置重试机制,最多60smicroPayWithPos
(Map<String, String> reqData, int connectTimeoutMs) 提交刷卡支付,针对软POS,尽可能做成功 内置重试机制,最多60sorderQuery
(Map<String, String> reqData) 作用:查询订单
场景:刷卡支付、公共号支付、扫码支付、APP支付orderQuery
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:查询订单
场景:刷卡支付、公共号支付、扫码支付、APP支付processResponseXml
(String xmlStr) 处理 HTTPS API返回数据,转换成Map对象。作用:申请退款
场景:刷卡支付、公共号支付、扫码支付、APP支付作用:申请退款
场景:刷卡支付、公共号支付、扫码支付、APP支付
其他:需要证书refundQuery
(Map<String, String> reqData) 作用:退款查询
场景:刷卡支付、公共号支付、扫码支付、APP支付refundQuery
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:退款查询
场景:刷卡支付、公共号支付、扫码支付、APP支付作用:交易保障
场景:刷卡支付、公共号支付、扫码支付、APP支付作用:交易保障
场景:刷卡支付、公共号支付、扫码支付、APP支付requestWithCert
(String urlSuffix, Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 需要证书的请求requestWithoutCert
(String urlSuffix, Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 不需要证书的请求作用:撤销订单
场景:刷卡支付作用:撤销订单
场景:刷卡支付
其他:需要证书作用:转换短链接
场景:刷卡支付、扫码支付作用:转换短链接
场景:刷卡支付、扫码支付unifiedOrder
(Map<String, String> reqData) 作用:统一下单
场景:公共号支付、扫码支付、APP支付unifiedOrder
(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) 作用:统一下单
场景:公共号支付、扫码支付、APP支付
-
Field Details
-
config
-
signType
-
autoReport
private boolean autoReport -
useSandbox
private boolean useSandbox -
notifyUrl
-
wxPayRequest
-
-
Constructor Details
-
Method Details
-
fillRequestData
向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign
该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口- Parameters:
reqData
-- Returns:
- Throws:
Exception
-
isResponseSignatureValid
判断xml数据的sign是否有效,必须包含sign字段,否则返回false。- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- 签名是否有效
- Throws:
Exception
-
isPayResultNotifySignatureValid
判断支付结果通知中的sign是否有效- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- 签名是否有效
- Throws:
Exception
-
requestWithoutCert
public String requestWithoutCert(String urlSuffix, Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception不需要证书的请求- Parameters:
urlSuffix
- StringreqData
- 向wxpay post的请求数据connectTimeoutMs
- 超时时间,单位是毫秒readTimeoutMs
- 超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
requestWithCert
public String requestWithCert(String urlSuffix, Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception需要证书的请求- Parameters:
urlSuffix
- StringreqData
- 向wxpay post的请求数据 MapconnectTimeoutMs
- 超时时间,单位是毫秒readTimeoutMs
- 超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
processResponseXml
处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。- Parameters:
xmlStr
- API返回的XML格式数据- Returns:
- Map类型数据
- Throws:
Exception
-
microPay
作用:提交刷卡支付
场景:刷卡支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
microPay
public Map<String,String> microPay(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:提交刷卡支付
场景:刷卡支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
microPayWithPos
提交刷卡支付,针对软POS,尽可能做成功 内置重试机制,最多60s- Parameters:
reqData
-- Returns:
- Throws:
Exception
-
microPayWithPos
public Map<String,String> microPayWithPos(Map<String, String> reqData, int connectTimeoutMs) throws Exception提交刷卡支付,针对软POS,尽可能做成功 内置重试机制,最多60s- Parameters:
reqData
-connectTimeoutMs
-- Returns:
- Throws:
Exception
-
unifiedOrder
作用:统一下单
场景:公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
unifiedOrder
public Map<String,String> unifiedOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:统一下单
场景:公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
orderQuery
作用:查询订单
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
orderQuery
public Map<String,String> orderQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:查询订单
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据 intconnectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
reverse
作用:撤销订单
场景:刷卡支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
reverse
public Map<String,String> reverse(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:撤销订单
场景:刷卡支付
其他:需要证书- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
closeOrder
作用:关闭订单
场景:公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
closeOrder
public Map<String,String> closeOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:关闭订单
场景:公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
refund
作用:申请退款
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
refund
public Map<String,String> refund(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:申请退款
场景:刷卡支付、公共号支付、扫码支付、APP支付
其他:需要证书- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
refundQuery
作用:退款查询
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
refundQuery
public Map<String,String> refundQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:退款查询
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
downloadBill
作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
downloadBill
public Map<String,String> downloadBill(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:对账单下载
场景:刷卡支付、公共号支付、扫码支付、APP支付
其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data, 其中return_code为`SUCCESS`,data为对账单数据。- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- 经过封装的API返回数据
- Throws:
Exception
-
report
作用:交易保障
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
report
public Map<String,String> report(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:交易保障
场景:刷卡支付、公共号支付、扫码支付、APP支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-
shortUrl
作用:转换短链接
场景:刷卡支付、扫码支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
shortUrl
public Map<String,String> shortUrl(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:转换短链接
场景:刷卡支付、扫码支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
authCodeToOpenid
作用:授权码查询OPENID接口
场景:刷卡支付- Parameters:
reqData
- 向wxpay post的请求数据- Returns:
- API返回数据
- Throws:
Exception
-
authCodeToOpenid
public Map<String,String> authCodeToOpenid(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception作用:授权码查询OPENID接口
场景:刷卡支付- Parameters:
reqData
- 向wxpay post的请求数据connectTimeoutMs
- 连接超时时间,单位是毫秒readTimeoutMs
- 读超时时间,单位是毫秒- Returns:
- API返回数据
- Throws:
Exception
-