mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #3063 【微信支付】增加服务商模式关闭订单的接口
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 服务商关闭订单请求对象类
|
||||
* 文档见:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_3.shtml
|
||||
*
|
||||
* @author Guo Shuai
|
||||
* @version 1.0
|
||||
* @date 2023/3/2
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxPayPartnerOrderCloseV3Request implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:服务商商户号
|
||||
* 变量名:sp_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 服务商商户号,由微信支付生成并下发。
|
||||
* 示例值:1230000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sp_mchid")
|
||||
private String spMchId;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:特约商户商户号
|
||||
* 变量名:sp_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 特约商户商户号,由微信支付生成并下发。
|
||||
* 示例值:1230000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchId;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户订单号
|
||||
* 变量名:out_trade_no
|
||||
* 是否必填:是
|
||||
* 类型:string[6,32]
|
||||
* 描述:
|
||||
* 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
|
||||
* 示例值:1217752501201407033233368018
|
||||
* </pre>
|
||||
*/
|
||||
private transient String outTradeNo;
|
||||
}
|
||||
@@ -21,19 +21,6 @@ import java.util.List;
|
||||
@Accessors(chain = true)
|
||||
public class WxPayPartnerRefundV3Request extends WxPayRefundV3Request implements Serializable {
|
||||
private static final long serialVersionUID = -1L;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子商户的商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 32]
|
||||
* 描述:
|
||||
* 子商户商户号,由微信支付生成并下发。
|
||||
* 示例值:1230000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchId;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:退款资金来源
|
||||
|
||||
@@ -238,6 +238,17 @@ public class WxPayRefundV3Request implements Serializable {
|
||||
private Integer refundQuantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子商户的商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1, 32]
|
||||
* 描述:
|
||||
* 子商户商户号,由微信支付生成并下发。
|
||||
* 示例值:1230000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.github.binarywang.wxpay.bean.result;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.enums.PartnerTradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.v3.util.SignUtils;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@@ -132,4 +133,32 @@ public class WxPayUnifiedOrderV3Result implements Serializable {
|
||||
throw new WxRuntimeException("不支持的支付类型");
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getPartnerPayInfo(PartnerTradeTypeEnum tradeType, String appId, String mchId, PrivateKey privateKey) {
|
||||
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
||||
String nonceStr = SignUtils.genRandomStr();
|
||||
switch (tradeType) {
|
||||
case JSAPI:
|
||||
JsapiResult jsapiResult = new JsapiResult();
|
||||
jsapiResult.setAppId(appId).setTimeStamp(timestamp)
|
||||
.setPackageValue("prepay_id=" + this.prepayId).setNonceStr(nonceStr)
|
||||
//签名类型,默认为RSA,仅支持RSA。
|
||||
.setSignType("RSA").setPaySign(SignUtils.sign(jsapiResult.getSignStr(), privateKey));
|
||||
return (T) jsapiResult;
|
||||
case H5:
|
||||
return (T) this.h5Url;
|
||||
case APP:
|
||||
AppResult appResult = new AppResult();
|
||||
appResult.setAppid(appId).setPrepayId(this.prepayId).setPartnerId(mchId)
|
||||
.setNoncestr(nonceStr).setTimestamp(timestamp)
|
||||
//暂填写固定值Sign=WXPay
|
||||
.setPackageValue("Sign=WXPay")
|
||||
.setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
|
||||
return (T) appResult;
|
||||
case NATIVE:
|
||||
return (T) this.codeUrl;
|
||||
default:
|
||||
throw new WxRuntimeException("不支持的支付类型");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.github.binarywang.wxpay.bean.result.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*
|
||||
* @author thinsstar
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PartnerTradeTypeEnum {
|
||||
/**
|
||||
* APP
|
||||
*/
|
||||
APP("/v3/pay/partner/transactions/app", "/v3/combine-transactions/app"),
|
||||
/**
|
||||
* JSAPI 或 小程序
|
||||
*/
|
||||
JSAPI("/v3/pay/partner/transactions/jsapi", "/v3/combine-transactions/jsapi"),
|
||||
/**
|
||||
* NATIVE
|
||||
*/
|
||||
NATIVE("/v3/pay/partner/transactions/native", "/v3/combine-transactions/native"),
|
||||
/**
|
||||
* H5
|
||||
*/
|
||||
H5("/v3/pay/partner/transactions/h5", "/v3/combine-transactions/h5");
|
||||
|
||||
/**
|
||||
* 单独下单url
|
||||
*/
|
||||
private final String partnerUrl;
|
||||
|
||||
/**
|
||||
* 合并下单url
|
||||
*/
|
||||
private final String combineUrl;
|
||||
}
|
||||
Reference in New Issue
Block a user