mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 20:57:47 +08:00
🆕 #1749 微信支付增加电商收付通支付回调处理相关方法
* new:电商收付通支付回调处理 Co-authored-by: 曾浩 <epdcgsi@dingtalk.com>
This commit is contained in:
parent
935988530d
commit
6927eaa139
@ -0,0 +1,359 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 合单支付 通知结果
|
||||
* <pre>
|
||||
* 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_7.shtml
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CombineTransactionsNotifyResult implements Serializable {
|
||||
|
||||
/**
|
||||
* 源数据
|
||||
*/
|
||||
private NotifyResponse rawData;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:合单商户appid
|
||||
* 变量名:combine_appid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 合单发起方的appid。(即电商平台appid)
|
||||
* 示例值:wxd678efh567hg6787
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "combine_appid")
|
||||
private String combineAppid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:合单商户号
|
||||
* 变量名:combine_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 合单发起方商户号。(即电商平台mchid)
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "combine_mchid")
|
||||
private String combineMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:合单商户订单号
|
||||
* 变量名:combine_out_trade_no
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 合单支付总订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
|
||||
* 示例值:P20150806125346
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "combine_out_trade_no")
|
||||
private String combineOutTradeNo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+场景信息
|
||||
* 变量名:scene_info
|
||||
* 是否必填:否
|
||||
* 类型:object
|
||||
* 描述:支付场景信息描述
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "scene_info")
|
||||
private SceneInfo sceneInfo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+子单信息
|
||||
* 变量名:sub_orders
|
||||
* 是否必填:是
|
||||
* 类型:array
|
||||
* 描述:
|
||||
* 最多支持子单条数:50
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_orders")
|
||||
private List<SubOrders> subOrders;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+支付者
|
||||
* 变量名:combine_payer_info
|
||||
* 是否必填:否
|
||||
* 类型:object
|
||||
* 描述:示例值:见请求示例
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "combine_payer_info")
|
||||
private CombinePayerInfo combinePayerInfo;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class SubOrders implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子单商户号
|
||||
* 变量名:mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 子单发起方商户号,必须与发起方Appid有绑定关系。(即电商平台mchid)
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "mchid")
|
||||
private String mchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:交易类型
|
||||
* 变量名:trade_type
|
||||
* 是否必填:是
|
||||
* 类型:string (16)
|
||||
* 描述:
|
||||
* 枚举值:
|
||||
* NATIVE:扫码支付
|
||||
* JSAPI:公众号支付
|
||||
* APP:APP支付
|
||||
* MWEB:H5支付
|
||||
* 示例值: JSAPI
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "trade_type")
|
||||
private String tradeType;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:交易状态
|
||||
* 变量名:trade_state
|
||||
* 是否必填:是
|
||||
* 类型:string (32)
|
||||
* 描述:
|
||||
* 枚举值:
|
||||
* SUCCESS:支付成功
|
||||
* REFUND:转入退款
|
||||
* NOTPAY:未支付
|
||||
* CLOSED:已关闭
|
||||
* USERPAYING:用户支付中
|
||||
* PAYERROR:支付失败(其他原因,如银行返回失败)
|
||||
* 示例值: SUCCESS
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "trade_state")
|
||||
private String tradeState;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:付款银行
|
||||
* 变量名:bank_type
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:
|
||||
* 银行类型,采用字符串类型的银行标识。
|
||||
* 示例值:CMC
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "bank_type")
|
||||
private String bankType;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:附加信息
|
||||
* 变量名:attach
|
||||
* 是否必填:是
|
||||
* 类型:string(128)
|
||||
* 描述:
|
||||
* 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
|
||||
* 示例值:深圳分店
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "attach")
|
||||
private String attach;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:支付完成时间
|
||||
* 变量名:success_time
|
||||
* 是否必填:是
|
||||
* 类型:string(16)
|
||||
* 描述:
|
||||
* 订单支付时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss:sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss:sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
|
||||
* 示例值:2015-05-20T13:29:35.120+08:00
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "success_time")
|
||||
private String successTime;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信订单号
|
||||
* 变量名:transaction_id
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 微信支付订单号。
|
||||
* 示例值: 1009660380201506130728806387
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子单商户订单号
|
||||
* 变量名:out_trade_no
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
|
||||
* 特殊规则:最小字符长度为6
|
||||
* 示例值:20150806125346
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "out_trade_no")
|
||||
private String outTradeNo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 二级商户商户号,由微信支付生成并下发。
|
||||
* 注意:仅适用于电商平台 服务商
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+订单金额
|
||||
* 变量名:amount
|
||||
* 是否必填:是
|
||||
* 类型:object
|
||||
* 描述:订单金额信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "amount")
|
||||
private Amount amount;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class SceneInfo implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户端设备号
|
||||
* 变量名:device_id
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:
|
||||
* 终端设备号(门店号或收银设备ID)。
|
||||
* 特殊规则:长度最小7个字节
|
||||
* 示例值:POS1:1
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "device_id")
|
||||
private String deviceId;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class CombinePayerInfo implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户标识
|
||||
* 变量名:openid
|
||||
* 是否必填:是
|
||||
* 类型:string(128)
|
||||
* 描述:
|
||||
* 使用合单appid获取的对应用户openid。是用户在商户appid下的唯一标识。
|
||||
* 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "openid")
|
||||
private String openid;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Amount implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:标价金额
|
||||
* 变量名:total_amount
|
||||
* 是否必填:是
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 子单金额,单位为分。
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "total_amount")
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:标价币种
|
||||
* 变量名:currency
|
||||
* 是否必填:是
|
||||
* 类型:string(8)
|
||||
* 描述:
|
||||
* 符合ISO 4217标准的三位字母代码,人民币:CNY。
|
||||
* 示例值:CNY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "currency")
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:现金支付金额
|
||||
* 变量名:payer_amount
|
||||
* 是否必填:是
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 订单现金支付金额。
|
||||
* 示例值:10
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "payer_amount")
|
||||
private Integer payerAmount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:现金支付币种
|
||||
* 变量名:payer_currency
|
||||
* 是否必填:是
|
||||
* 类型:string(8)
|
||||
* 描述:
|
||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY。
|
||||
* 示例值: CNY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "payer_currency")
|
||||
private String payerCurrency;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 通知数据
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class NotifyResponse implements Serializable {
|
||||
|
||||
@SerializedName(value = "id")
|
||||
private String id;
|
||||
|
||||
@SerializedName(value = "create_time")
|
||||
private String createTime;
|
||||
|
||||
@SerializedName(value = "event_type")
|
||||
private String eventType;
|
||||
|
||||
@SerializedName(value = "resource_type")
|
||||
private String resourceType;
|
||||
|
||||
@SerializedName(value = "resource")
|
||||
private Resource resource;
|
||||
|
||||
@SerializedName(value = "summary")
|
||||
private String summary;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Resource implements Serializable {
|
||||
|
||||
@SerializedName(value = "algorithm")
|
||||
private String algorithm;
|
||||
|
||||
@SerializedName(value = "ciphertext")
|
||||
private String ciphertext;
|
||||
|
||||
@SerializedName(value = "associated_data")
|
||||
private String associatedData;
|
||||
|
||||
@SerializedName(value = "nonce")
|
||||
private String nonce;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,592 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 普通支付 通知结果
|
||||
* <pre>
|
||||
* 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/e_transactions/chapter3_11.shtml
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PartnerTransactionsNotifyResult implements Serializable {
|
||||
|
||||
/**
|
||||
* 源数据
|
||||
*/
|
||||
private NotifyResponse rawData;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:服务商公众号ID
|
||||
* 变量名:sp_appid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 服务商申请的公众号或移动应用appid。
|
||||
* 示例值:wx8888888888888888
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sp_appid")
|
||||
private String spAppid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:服务商户号
|
||||
* 变量名:sp_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 服务商户号,由微信支付生成并下发
|
||||
* 示例值:1230000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sp_mchid")
|
||||
private String spMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户公众号ID
|
||||
* 变量名:sub_appid
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 二级商户申请的公众号或移动应用appid。
|
||||
* 示例值:wxd678efh567hg6999
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_appid")
|
||||
private String subAppid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 二级商户的商户号,有微信支付生成并下发。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+商户订单号
|
||||
* 变量名:out_trade_no
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,详见【商户订单号】。
|
||||
* 特殊规则:最小字符长度为6
|
||||
* 示例值:1217752501201407033233368018
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "out_trade_no")
|
||||
private String outTradeNo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信支付订单号
|
||||
* 变量名:transaction_id
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述:微信支付系统生成的订单号。
|
||||
* 示例值:1217752501201407033233368018
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:交易类型
|
||||
* 变量名:trade_type
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:交易类型,枚举值:
|
||||
* JSAPI:公众号支付
|
||||
* NATIVE:扫码支付
|
||||
* APP:APP支付
|
||||
* MICROPAY:付款码支付
|
||||
* MWEB:H5支付
|
||||
* FACEPAY:刷脸支付
|
||||
*
|
||||
* 示例值: MICROPAY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "trade_type")
|
||||
private String tradeType;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:交易状态
|
||||
* 变量名:trade_state
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:交易状态,枚举值:
|
||||
* SUCCESS:支付成功
|
||||
* REFUND:转入退款
|
||||
* NOTPAY:未支付
|
||||
* CLOSED:已关闭
|
||||
* REVOKED:已撤销(付款码支付)
|
||||
* USERPAYING:用户支付中(付款码支付)
|
||||
* PAYERROR:支付失败(其他原因,如银行返回失败)
|
||||
*
|
||||
* 示例值:SUCCESS
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "trade_state")
|
||||
private String tradeState;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:交易状态描述
|
||||
* 变量名:trade_state_desc
|
||||
* 是否必填:是
|
||||
* 类型:string(256)
|
||||
* 描述:交易状态描述
|
||||
* 示例值:支付失败,请重新下单支付
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "trade_state_desc")
|
||||
private String tradeStateDesc;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:付款银行
|
||||
* 变量名:bank_type
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:银行类型,采用字符串类型的银行标识。
|
||||
* 示例值:CMC
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "bank_type")
|
||||
private String bankType;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:附加数据
|
||||
* 变量名:attach
|
||||
* 是否必填:否
|
||||
* 类型:string(128)
|
||||
* 描述:附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
|
||||
* 示例值:自定义数据
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "attach")
|
||||
private String attach;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:支付完成时间
|
||||
* 变量名:success_time
|
||||
* 是否必填:否
|
||||
* 类型:string(64)
|
||||
* 描述:支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
|
||||
* 示例值:2018-06-08T10:34:56+08:00
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "success_time")
|
||||
private String successTime;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:+支付者
|
||||
* 变量名:combine_payer_info
|
||||
* 是否必填:否
|
||||
* 类型:object
|
||||
* 描述:示例值:见请求示例
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "combine_payer_info")
|
||||
private CombinePayerInfo combinePayerInfo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:订单金额
|
||||
* 变量名:amount
|
||||
* 是否必填:是
|
||||
* 类型:object
|
||||
* 描述:订单金额信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "amount")
|
||||
private Amount amount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:场景信息
|
||||
* 变量名:scene_info
|
||||
* 是否必填:否
|
||||
* 类型:object
|
||||
* 描述:支付场景信息描述
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "scene_info")
|
||||
private SceneInfo sceneInfo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠功能
|
||||
* 变量名:promotion_detail
|
||||
* 是否必填:否
|
||||
* 类型:array
|
||||
* 描述:优惠功能,享受优惠时返回该字段。
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "promotion_detail")
|
||||
private List<PromotionDetail> promotionDetails;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class SceneInfo implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户端设备号
|
||||
* 变量名:device_id
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:
|
||||
* 终端设备号(门店号或收银设备ID)。
|
||||
* 特殊规则:长度最小7个字节
|
||||
* 示例值:POS1:1
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "device_id")
|
||||
private String deviceId;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class CombinePayerInfo implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户标识
|
||||
* 变量名:sp_openid
|
||||
* 是否必填:是
|
||||
* 类型:string(128)
|
||||
* 描述:
|
||||
* 用户在服务商appid下的唯一标识。
|
||||
* 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sp_openid")
|
||||
private String spOpenid;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户用户标识
|
||||
* 变量名:sub_openid
|
||||
* 是否必填:否
|
||||
* 类型:string(128)
|
||||
* 描述:
|
||||
* 用户在二级商户appid下的唯一标识。
|
||||
* 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_openid")
|
||||
private String subOpenid;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Amount implements Serializable {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:总金额
|
||||
* 变量名:total
|
||||
* 是否必填:否
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 订单总金额,单位为分
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "total")
|
||||
private Integer total;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户支付金额
|
||||
* 变量名:payer_total
|
||||
* 是否必填:否
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 用户支付金额,单位为分。
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "payer_total")
|
||||
private Integer payerTotal;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:货币类型
|
||||
* 变量名:currency
|
||||
* 是否必填:否
|
||||
* 类型:string(16)
|
||||
* 描述:
|
||||
* CNY:人民币,境内商户号仅支持人民币。
|
||||
* 示例值:CNY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "currency")
|
||||
private String currency;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:用户支付币种
|
||||
* 变量名:payer_currency
|
||||
* 是否必填:否
|
||||
* 类型:string(8)
|
||||
* 描述:
|
||||
* 用户支付币种
|
||||
* 示例值: CNY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "payer_currency")
|
||||
private String payerCurrency;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class PromotionDetail implements Serializable {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:券ID
|
||||
* 变量名:coupon_id
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述: 券ID
|
||||
* 示例值:109519
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "coupon_id")
|
||||
private String couponId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠名称
|
||||
* 变量名:name
|
||||
* 是否必填:否
|
||||
* 类型:string(64)
|
||||
* 描述: 优惠名称
|
||||
* 示例值:单品惠-6
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "name")
|
||||
private String name;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠范围
|
||||
* 变量名:scope
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述: 优惠名称
|
||||
* 示例值:
|
||||
* GLOBAL:全场代金券
|
||||
* SINGLE:单品优惠
|
||||
* 示例值:GLOBAL
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "scope")
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠类型
|
||||
* 变量名:type
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* CASH:充值
|
||||
* NOCASH:预充值
|
||||
* 示例值:CASH
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠券面额
|
||||
* 变量名:amount
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述: 优惠券面额
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "amount")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:活动ID
|
||||
* 变量名:stock_id
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述:活动ID
|
||||
* 示例值:931386
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "stock_id")
|
||||
private String stockId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信出资
|
||||
* 变量名:wechatpay_contribute
|
||||
* 是否必填:否
|
||||
* 类型:int
|
||||
* 描述:微信出资,单位为分
|
||||
* 示例值:0
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "wechatpay_contribute")
|
||||
private Integer wechatpayContribute;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户出资
|
||||
* 变量名:merchant_contribute
|
||||
* 是否必填:否
|
||||
* 类型:int
|
||||
* 描述:商户出资,单位为分
|
||||
* 示例值:0
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "merchant_contribute")
|
||||
private Integer merchantContribute;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:其他出资
|
||||
* 变量名:other_contribute
|
||||
* 是否必填:否
|
||||
* 类型:int
|
||||
* 描述:其他出资,单位为分
|
||||
* 示例值:0
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "other_contribute")
|
||||
private Integer otherContribute;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:优惠币种
|
||||
* 变量名:currency
|
||||
* 是否必填:否
|
||||
* 类型:String(16)
|
||||
* 描述:
|
||||
* CNY:人民币,境内商户号仅支持人民币。
|
||||
* 示例值:CNY
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "currency")
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:单品列表
|
||||
* 变量名:goods_detail
|
||||
* 是否必填:否
|
||||
* 类型:array
|
||||
* 描述:单品列表信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "goods_detail")
|
||||
private List<GoodsDetail> goodsDetails;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class GoodsDetail implements Serializable {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品编码
|
||||
* 变量名:goods_id
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:商品编码
|
||||
* 示例值:M1006
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "goods_id")
|
||||
private String goodsId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品数量
|
||||
* 变量名:quantity
|
||||
* 是否必填:是
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 用户购买的数量
|
||||
* 示例值:1
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "quantity")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品单价
|
||||
* 变量名:unit_price
|
||||
* 是否必填:是
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 商品单价,单位为分
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "unit_price")
|
||||
private Integer unitPrice;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品优惠金额
|
||||
* 变量名:discount_amount
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:商品优惠金额
|
||||
* 示例值:0
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "discount_amount")
|
||||
private Integer discountAmount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品备注
|
||||
* 变量名:goods_remark
|
||||
* 是否必填:否
|
||||
* 类型:string(128)
|
||||
* 描述:商品备注信息
|
||||
* 示例值:商品备注信息
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "goods_remark")
|
||||
private String goodsRemark;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 微信通知接口头部信息,需要做签名验证
|
||||
* 文档地址: https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/qian-ming-yan-zheng
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SignatureHeader implements Serializable {
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private String timeStamp;
|
||||
|
||||
/**
|
||||
* 随机串
|
||||
*/
|
||||
private String nonce;
|
||||
|
||||
/**
|
||||
* 已签名字符串
|
||||
*/
|
||||
private String signed;
|
||||
|
||||
/**
|
||||
* 证书序列号
|
||||
*/
|
||||
private String serialNo;
|
||||
}
|
@ -97,7 +97,7 @@ public class TransactionsResult implements Serializable {
|
||||
//签名类型,默认为RSA,仅支持RSA。
|
||||
.setSignType("RSA").setPaySign(SignUtils.sign(jsapiResult.getSignStr(), privateKey));
|
||||
return (T) jsapiResult;
|
||||
case H5:
|
||||
case MWEB:
|
||||
return (T) this.h5Url;
|
||||
case APP:
|
||||
AppResult appResult = new AppResult();
|
||||
|
@ -13,7 +13,7 @@ public enum TradeTypeEnum {
|
||||
APP("/v3/combine-transactions/app","/v3/pay/partner/transactions/app"),
|
||||
JSAPI("/v3/combine-transactions/jsapi","/v3/pay/partner/transactions/jsapi"),
|
||||
NATIVE("/v3/combine-transactions/native","/v3/pay/partner/transactions/native"),
|
||||
H5("/v3/combine-transactions/h5","/v3/pay/partner/transactions/h5")
|
||||
MWEB("/v3/combine-transactions/h5","/v3/pay/partner/transactions/h5")
|
||||
;
|
||||
|
||||
/**
|
||||
|
@ -67,6 +67,18 @@ public interface EcommerceService {
|
||||
*/
|
||||
<T> T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 合单支付通知回调数据处理
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/e-combine.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param notifyData 通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据
|
||||
*/
|
||||
CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 服务商模式普通支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
|
||||
@ -78,4 +90,16 @@ public interface EcommerceService {
|
||||
* @return 调起支付需要的参数
|
||||
*/
|
||||
<T> T partnerTransactions(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 普通支付通知回调数据处理
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/e_transactions.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param notifyData 通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据
|
||||
*/
|
||||
PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
|
||||
}
|
||||
|
@ -5,12 +5,17 @@ import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.EcommerceService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.v3.util.AesUtils;
|
||||
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Objects;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class EcommerceServiceImpl implements EcommerceService {
|
||||
@ -49,6 +54,27 @@ public class EcommerceServiceImpl implements EcommerceService {
|
||||
request.getCombineMchid(), payService.getConfig().getPrivateKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
|
||||
if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){
|
||||
throw new WxPayException("非法请求,头部信息验证失败");
|
||||
}
|
||||
NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class);
|
||||
NotifyResponse.Resource resource = response.getResource();
|
||||
String cipherText = resource.getCiphertext();
|
||||
String associatedData = resource.getAssociatedData();
|
||||
String nonce = resource.getNonce();
|
||||
String apiV3Key = this.payService.getConfig().getApiV3Key();
|
||||
try {
|
||||
String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
|
||||
CombineTransactionsNotifyResult notifyResult = GSON.fromJson(result, CombineTransactionsNotifyResult.class);
|
||||
notifyResult.setRawData(response);
|
||||
return notifyResult;
|
||||
} catch (GeneralSecurityException | IOException e) {
|
||||
throw new WxPayException("解析报文异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T partnerTransactions(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException {
|
||||
String url = this.payService.getPayBaseUrl() + tradeType.getPartnerUrl();
|
||||
@ -57,4 +83,34 @@ public class EcommerceServiceImpl implements EcommerceService {
|
||||
return result.getPayInfo(tradeType, request.getSpAppid(),
|
||||
request.getSpMchid(), payService.getConfig().getPrivateKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
|
||||
if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){
|
||||
throw new WxPayException("非法请求,头部信息验证失败");
|
||||
}
|
||||
NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class);
|
||||
NotifyResponse.Resource resource = response.getResource();
|
||||
String cipherText = resource.getCiphertext();
|
||||
String associatedData = resource.getAssociatedData();
|
||||
String nonce = resource.getNonce();
|
||||
String apiV3Key = this.payService.getConfig().getApiV3Key();
|
||||
try {
|
||||
String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
|
||||
PartnerTransactionsNotifyResult notifyResult = GSON.fromJson(result, PartnerTransactionsNotifyResult.class);
|
||||
notifyResult.setRawData(response);
|
||||
return notifyResult;
|
||||
} catch (GeneralSecurityException | IOException e) {
|
||||
throw new WxPayException("解析报文异常!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean verifyNotifySign(SignatureHeader header, String data) {
|
||||
String beforeSign = String.format("%s\n%s\n%s\n",
|
||||
header.getTimeStamp(),
|
||||
header.getNonce(),
|
||||
data);
|
||||
return payService.getConfig().getVerifier().verify(header.getSerialNo(),
|
||||
beforeSign.getBytes(StandardCharsets.UTF_8), header.getSigned());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user