Class WXPay

java.lang.Object
com.bytedesk.wechat.pay.sdk.WXPay

public class WXPay extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • fillRequestData

      public Map<String,String> fillRequestData(Map<String,String> reqData) throws Exception
      向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign
      该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口
      Parameters:
      reqData -
      Returns:
      Throws:
      Exception
    • isResponseSignatureValid

      public boolean isResponseSignatureValid(Map<String,String> reqData) throws Exception
      判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
      Parameters:
      reqData - 向wxpay post的请求数据
      Returns:
      签名是否有效
      Throws:
      Exception
    • isPayResultNotifySignatureValid

      public boolean isPayResultNotifySignatureValid(Map<String,String> reqData) throws Exception
      判断支付结果通知中的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 - String
      reqData - 向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 - String
      reqData - 向wxpay post的请求数据 Map
      connectTimeoutMs - 超时时间,单位是毫秒
      readTimeoutMs - 超时时间,单位是毫秒
      Returns:
      API返回数据
      Throws:
      Exception
    • processResponseXml

      public Map<String,String> processResponseXml(String xmlStr) throws Exception
      处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
      Parameters:
      xmlStr - API返回的XML格式数据
      Returns:
      Map类型数据
      Throws:
      Exception
    • microPay

      public Map<String,String> microPay(Map<String,String> reqData) throws Exception
      作用:提交刷卡支付
      场景:刷卡支付
      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

      public Map<String,String> microPayWithPos(Map<String,String> reqData) throws Exception
      提交刷卡支付,针对软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

      public Map<String,String> unifiedOrder(Map<String,String> reqData) throws Exception
      作用:统一下单
      场景:公共号支付、扫码支付、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

      public Map<String,String> orderQuery(Map<String,String> reqData) throws Exception
      作用:查询订单
      场景:刷卡支付、公共号支付、扫码支付、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的请求数据 int
      connectTimeoutMs - 连接超时时间,单位是毫秒
      readTimeoutMs - 读超时时间,单位是毫秒
      Returns:
      API返回数据
      Throws:
      Exception
    • reverse

      public Map<String,String> reverse(Map<String,String> reqData) throws Exception
      作用:撤销订单
      场景:刷卡支付
      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

      public Map<String,String> closeOrder(Map<String,String> reqData) throws Exception
      作用:关闭订单
      场景:公共号支付、扫码支付、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

      public Map<String,String> refund(Map<String,String> reqData) throws Exception
      作用:申请退款
      场景:刷卡支付、公共号支付、扫码支付、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

      public Map<String,String> refundQuery(Map<String,String> reqData) throws Exception
      作用:退款查询
      场景:刷卡支付、公共号支付、扫码支付、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

      public Map<String,String> downloadBill(Map<String,String> reqData) throws Exception
      作用:对账单下载(成功时返回对账单数据,失败时返回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

      public Map<String,String> report(Map<String,String> reqData) throws Exception
      作用:交易保障
      场景:刷卡支付、公共号支付、扫码支付、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

      public Map<String,String> shortUrl(Map<String,String> reqData) throws Exception
      作用:转换短链接
      场景:刷卡支付、扫码支付
      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

      public Map<String,String> authCodeToOpenid(Map<String,String> reqData) throws Exception
      作用:授权码查询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