mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
🎨 微信支付分相关接口代码重构规范化
This commit is contained in:
parent
8709a9c5a7
commit
39cea92171
@ -55,7 +55,7 @@ public class WxPayAutoConfiguration {
|
|||||||
payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
|
payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
|
||||||
payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
|
payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
|
||||||
payConfig.setCertSerialNo(StringUtils.trimToNull(this.properties.getCertSerialNo()));
|
payConfig.setCertSerialNo(StringUtils.trimToNull(this.properties.getCertSerialNo()));
|
||||||
payConfig.setApiv3Key(StringUtils.trimToNull(this.properties.getApiv3Key()));
|
payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiv3Key()));
|
||||||
|
|
||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
return wxPayService;
|
return wxPayService;
|
||||||
|
@ -82,19 +82,10 @@
|
|||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.9.7</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
<version>1.2.58</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 明细.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Detail implements Serializable {
|
||||||
|
private static final long serialVersionUID = -3901373259400050385L;
|
||||||
|
/**
|
||||||
|
* seq : 1
|
||||||
|
* amount : 900
|
||||||
|
* paid_type : NEWTON
|
||||||
|
* paid_time : 20091225091210
|
||||||
|
* transaction_id : 15646546545165651651
|
||||||
|
*/
|
||||||
|
@SerializedName("seq")
|
||||||
|
private int seq;
|
||||||
|
@SerializedName("amount")
|
||||||
|
private int amount;
|
||||||
|
@SerializedName("paid_type")
|
||||||
|
private String paidType;
|
||||||
|
@SerializedName("paid_time")
|
||||||
|
private String paidTime;
|
||||||
|
@SerializedName("transaction_id")
|
||||||
|
private String transactionId;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务位置信息.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Location implements Serializable {
|
||||||
|
private static final long serialVersionUID = -4510224826631515344L;
|
||||||
|
/**
|
||||||
|
* start_location : 嗨客时尚主题展餐厅
|
||||||
|
* end_location : 嗨客时尚主题展餐厅
|
||||||
|
*/
|
||||||
|
@SerializedName("start_location")
|
||||||
|
private String startLocation;
|
||||||
|
@SerializedName("end_location")
|
||||||
|
private String endLocation;
|
||||||
|
}
|
@ -1,45 +0,0 @@
|
|||||||
package com.github.binarywang.wxpay.bean.payscore;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付分确认订单跟支付回调对象
|
|
||||||
* @author doger.wang
|
|
||||||
* @date 2020/5/14 12:18
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class NotifyData {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* id : EV-2018022511223320873
|
|
||||||
* create_time : 20180225112233
|
|
||||||
* resource_type : encrypt-resource
|
|
||||||
* event_type : PAYSCORE.USER_CONFIRM
|
|
||||||
* resource : {"algorithm":"AEAD_AES_256_GCM","ciphertext":"...","nonce":"...","associated_data":""}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String create_time;
|
|
||||||
private String resource_type;
|
|
||||||
private String event_type;
|
|
||||||
private Resource resource;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class Resource {
|
|
||||||
/**
|
|
||||||
* algorithm : AEAD_AES_256_GCM
|
|
||||||
* ciphertext : ...
|
|
||||||
* nonce : ...
|
|
||||||
* associated_data :
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String algorithm;
|
|
||||||
private String ciphertext;
|
|
||||||
private String nonce;
|
|
||||||
private String associated_data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付分确认订单跟支付回调对象
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020/5/14 12:18
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class PayScoreNotifyData implements Serializable {
|
||||||
|
private static final long serialVersionUID = -8538014389773390989L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id : EV-2018022511223320873
|
||||||
|
* create_time : 20180225112233
|
||||||
|
* resource_type : encrypt-resource
|
||||||
|
* event_type : PAYSCORE.USER_CONFIRM
|
||||||
|
* resource : {"algorithm":"AEAD_AES_256_GCM","ciphertext":"...","nonce":"...","associated_data":""}
|
||||||
|
*/
|
||||||
|
@SerializedName("id")
|
||||||
|
private String id;
|
||||||
|
@SerializedName("create_time")
|
||||||
|
private String createTime;
|
||||||
|
@SerializedName("resource_type")
|
||||||
|
private String resourceType;
|
||||||
|
@SerializedName("event_type")
|
||||||
|
private String eventType;
|
||||||
|
@SerializedName("resource")
|
||||||
|
private Resource resource;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Resource implements Serializable {
|
||||||
|
private static final long serialVersionUID = 8530711804335261449L;
|
||||||
|
/**
|
||||||
|
* algorithm : AEAD_AES_256_GCM
|
||||||
|
* ciphertext : ...
|
||||||
|
* nonce : ...
|
||||||
|
* associated_data :
|
||||||
|
*/
|
||||||
|
@SerializedName("algorithm")
|
||||||
|
private String algorithm;
|
||||||
|
@SerializedName("ciphertext")
|
||||||
|
private String cipherText;
|
||||||
|
@SerializedName("nonce")
|
||||||
|
private String nonce;
|
||||||
|
@SerializedName("associated_data")
|
||||||
|
private String associatedData;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后付费商户优惠.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PostDiscount implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2764537888242763379L;
|
||||||
|
/**
|
||||||
|
* name : 满20减1元
|
||||||
|
* description : 不与其他优惠叠加
|
||||||
|
*/
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
|
@SerializedName("description")
|
||||||
|
private String description;
|
||||||
|
@SerializedName("count")
|
||||||
|
private int count;
|
||||||
|
@SerializedName("amount")
|
||||||
|
private int amount;
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后付费项目.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PostPayment implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2007722927556382895L;
|
||||||
|
/**
|
||||||
|
* name : 就餐费用服务费
|
||||||
|
* amount : 4000
|
||||||
|
* description : 就餐人均100元服务费:100/小时
|
||||||
|
* count : 1
|
||||||
|
*/
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
|
@SerializedName("amount")
|
||||||
|
private int amount;
|
||||||
|
@SerializedName("description")
|
||||||
|
private String description;
|
||||||
|
@SerializedName("count")
|
||||||
|
private int count;
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单风险金信息.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RiskFund implements Serializable {
|
||||||
|
private static final long serialVersionUID = -3583406084396059152L;
|
||||||
|
/**
|
||||||
|
* name : ESTIMATE_ORDER_COST
|
||||||
|
* amount : 10000
|
||||||
|
* description : 就餐的预估费用
|
||||||
|
*/
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
|
@SerializedName("amount")
|
||||||
|
private int amount;
|
||||||
|
@SerializedName("description")
|
||||||
|
private String description;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务时间范围.
|
||||||
|
*
|
||||||
|
* @author doger.wang
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TimeRange implements Serializable {
|
||||||
|
private static final long serialVersionUID = 8169562173656314930L;
|
||||||
|
/**
|
||||||
|
* start_time : 20091225091010
|
||||||
|
* end_time : 20091225121010
|
||||||
|
*/
|
||||||
|
@SerializedName("start_time")
|
||||||
|
private String startTime;
|
||||||
|
@SerializedName("end_time")
|
||||||
|
private String endTime;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.bean.payscore;
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@ -13,118 +14,60 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class WxPayScoreRequest implements Serializable {
|
public class WxPayScoreRequest implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 364764508076146082L;
|
private static final long serialVersionUID = 364764508076146082L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* out_order_no : 1234323JKHDFE1243252
|
* out_order_no : 1234323JKHDFE1243252
|
||||||
* appid : wxd678efh567hg6787
|
* appid : wxd678efh567hg6787
|
||||||
* service_id : 500001
|
* service_id : 500001
|
||||||
* service_introduction : 某某酒店
|
* service_introduction : 某某酒店
|
||||||
* post_payments : [{"name":"就餐费用服务费","amount":4000,"description":"就餐人均100元服务费:100/小时","count":1}]
|
* post_payments : [{"name":"就餐费用服务费","amount":4000,"description":"就餐人均100元服务费:100/小时","count":1}]
|
||||||
* post_discounts : [{"name":"满20减1元","description":"不与其他优惠叠加"}]
|
* post_discounts : [{"name":"满20减1元","description":"不与其他优惠叠加"}]
|
||||||
* time_range : {"start_time":"20091225091010","end_time":"20091225121010"}
|
* time_range : {"start_time":"20091225091010","end_time":"20091225121010"}
|
||||||
* location : {"start_location":"嗨客时尚主题展餐厅","end_location":"嗨客时尚主题展餐厅"}
|
* location : {"start_location":"嗨客时尚主题展餐厅","end_location":"嗨客时尚主题展餐厅"}
|
||||||
* risk_fund : {"name":"ESTIMATE_ORDER_COST","amount":10000,"description":"就餐的预估费用"}
|
* risk_fund : {"name":"ESTIMATE_ORDER_COST","amount":10000,"description":"就餐的预估费用"}
|
||||||
* attach : Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald
|
* attach : Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald
|
||||||
* notify_url : https://api.test.com
|
* notify_url : https://api.test.com
|
||||||
* openid : oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
* openid : oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
||||||
* need_user_confirm : true
|
* need_user_confirm : true
|
||||||
*/
|
*/
|
||||||
|
@SerializedName("out_order_no")
|
||||||
|
private String outOrderNo;
|
||||||
|
@SerializedName("appid")
|
||||||
|
private String appid;
|
||||||
|
@SerializedName("service_id")
|
||||||
|
private String serviceId;
|
||||||
|
@SerializedName("service_introduction")
|
||||||
|
private String serviceIntroduction;
|
||||||
|
@SerializedName("time_range")
|
||||||
|
private TimeRange timeRange;
|
||||||
|
@SerializedName("location")
|
||||||
|
private Location location;
|
||||||
|
@SerializedName("risk_fund")
|
||||||
|
private RiskFund riskFund;
|
||||||
|
@SerializedName("attach")
|
||||||
|
private String attach;
|
||||||
|
@SerializedName("notify_url")
|
||||||
|
private String notifyUrl;
|
||||||
|
@SerializedName("openid")
|
||||||
|
private String openid;
|
||||||
|
@SerializedName("need_user_confirm")
|
||||||
|
private boolean needUserConfirm;
|
||||||
|
@SerializedName("profit_sharing")
|
||||||
|
private boolean profitSharing;
|
||||||
|
@SerializedName("post_payments")
|
||||||
|
private List<PostPayment> postPayments;
|
||||||
|
@SerializedName("post_discounts")
|
||||||
|
private List<PostDiscount> postDiscounts;
|
||||||
|
@SerializedName("total_amount")
|
||||||
|
private int totalAmount;
|
||||||
|
@SerializedName("reason")
|
||||||
|
private String reason;
|
||||||
|
@SerializedName("goods_tag")
|
||||||
|
private String goodsTag;
|
||||||
|
@SerializedName("type")
|
||||||
|
private String type;
|
||||||
|
@SerializedName("detail")
|
||||||
|
private Detail detail;
|
||||||
|
|
||||||
private String out_order_no;
|
|
||||||
private String appid;
|
|
||||||
private String service_id;
|
|
||||||
private String service_introduction;
|
|
||||||
private TimeRange time_range;
|
|
||||||
private Location location;
|
|
||||||
private RiskFund risk_fund;
|
|
||||||
private String attach;
|
|
||||||
private String notify_url;
|
|
||||||
private String openid;
|
|
||||||
private boolean need_user_confirm;
|
|
||||||
private boolean profit_sharing;
|
|
||||||
private List<PostPayments> post_payments;
|
|
||||||
private List<PostDiscounts> post_discounts;
|
|
||||||
private int total_amount;
|
|
||||||
private String reason;
|
|
||||||
private String goods_tag;
|
|
||||||
private String type;
|
|
||||||
private Detail detail;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class Detail {
|
|
||||||
private String paid_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class TimeRange {
|
|
||||||
/**
|
|
||||||
* start_time : 20091225091010
|
|
||||||
* end_time : 20091225121010
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String start_time;
|
|
||||||
private String end_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class Location {
|
|
||||||
/**
|
|
||||||
* start_location : 嗨客时尚主题展餐厅
|
|
||||||
* end_location : 嗨客时尚主题展餐厅
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String start_location;
|
|
||||||
private String end_location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class RiskFund {
|
|
||||||
/**
|
|
||||||
* name : ESTIMATE_ORDER_COST
|
|
||||||
* amount : 10000
|
|
||||||
* description : 就餐的预估费用
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private int amount;
|
|
||||||
private String description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class PostPayments {
|
|
||||||
/**
|
|
||||||
* name : 就餐费用服务费
|
|
||||||
* amount : 4000
|
|
||||||
* description : 就餐人均100元服务费:100/小时
|
|
||||||
* count : 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private int amount;
|
|
||||||
private String description;
|
|
||||||
private int count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class PostDiscounts {
|
|
||||||
/**
|
|
||||||
* name : 满20减1元
|
|
||||||
* description : 不与其他优惠叠加
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String description;
|
|
||||||
private int count;
|
|
||||||
private int amount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.bean.payscore;
|
package com.github.binarywang.wxpay.bean.payscore;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@ -15,119 +15,78 @@ import java.util.Map;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class WxPayScoreResult implements Serializable {
|
public class WxPayScoreResult implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 8809250065540275770L;
|
private static final long serialVersionUID = 8809250065540275770L;
|
||||||
/**
|
|
||||||
* appid : wxd678efh567hg6787
|
|
||||||
* mchid : 1230000109
|
|
||||||
* out_order_no : 1234323JKHDFE1243252
|
|
||||||
* service_id : 500001
|
|
||||||
* service_introduction : 某某酒店
|
|
||||||
* state : CREATED
|
|
||||||
* state_description : MCH_COMPLETE
|
|
||||||
* post_payments : [{"name":"就餐费用服务费","amount":4000,"description":"就餐人均100元服务费:100/小时","count":1}]
|
|
||||||
* post_discounts : [{"name":"满20减1元","description":"不与其他优惠叠加"}]
|
|
||||||
* risk_fund : {"name":" ESTIMATE_ORDER_COST","amount":10000,"description":"就餐的预估费用"}
|
|
||||||
* time_range : {"start_time":"20091225091010","end_time":"20091225121010"}
|
|
||||||
* location : {"start_location":"嗨客时尚主题展餐厅","end_location":"嗨客时尚主题展餐厅"}
|
|
||||||
* attach : Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald
|
|
||||||
* notify_url : https://api.test.com
|
|
||||||
* order_id : 15646546545165651651
|
|
||||||
* package : DJIOSQPYWDxsjdldeuwhdodwxasd_dDiodnwjh9we
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String appid;
|
/**
|
||||||
private String mchid;
|
* appid : wxd678efh567hg6787
|
||||||
private String out_order_no;
|
* mchid : 1230000109
|
||||||
private String service_id;
|
* out_order_no : 1234323JKHDFE1243252
|
||||||
private String service_introduction;
|
* service_id : 500001
|
||||||
private String state;
|
* service_introduction : 某某酒店
|
||||||
private String state_description;
|
* state : CREATED
|
||||||
private RiskFund risk_fund;
|
* state_description : MCH_COMPLETE
|
||||||
private TimeRange time_range;
|
* post_payments : [{"name":"就餐费用服务费","amount":4000,"description":"就餐人均100元服务费:100/小时","count":1}]
|
||||||
private Location location;
|
* post_discounts : [{"name":"满20减1元","description":"不与其他优惠叠加"}]
|
||||||
private String attach;
|
* risk_fund : {"name":" ESTIMATE_ORDER_COST","amount":10000,"description":"就餐的预估费用"}
|
||||||
private String notify_url;
|
* time_range : {"start_time":"20091225091010","end_time":"20091225121010"}
|
||||||
private String order_id;
|
* location : {"start_location":"嗨客时尚主题展餐厅","end_location":"嗨客时尚主题展餐厅"}
|
||||||
@JSONField(name = "package")
|
* attach : Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald
|
||||||
private String packageX;
|
* notify_url : https://api.test.com
|
||||||
private List<PostPayments> post_payments;
|
* order_id : 15646546545165651651
|
||||||
private List<PostDiscounts> post_discounts;
|
* package : DJIOSQPYWDxsjdldeuwhdodwxasd_dDiodnwjh9we
|
||||||
private boolean need_collection;
|
*/
|
||||||
|
@SerializedName("appid")
|
||||||
|
private String appid;
|
||||||
|
@SerializedName("mchid")
|
||||||
|
private String mchid;
|
||||||
|
@SerializedName("out_order_no")
|
||||||
|
private String outOrderNo;
|
||||||
|
@SerializedName("service_id")
|
||||||
|
private String serviceId;
|
||||||
|
@SerializedName("service_introduction")
|
||||||
|
private String serviceIntroduction;
|
||||||
|
@SerializedName("state")
|
||||||
|
private String state;
|
||||||
|
@SerializedName("state_description")
|
||||||
|
private String stateDescription;
|
||||||
|
@SerializedName("risk_fund")
|
||||||
|
private RiskFund riskFund;
|
||||||
|
@SerializedName("time_range")
|
||||||
|
private TimeRange timeRange;
|
||||||
|
@SerializedName("location")
|
||||||
|
private Location location;
|
||||||
|
@SerializedName("attach")
|
||||||
|
private String attach;
|
||||||
|
@SerializedName("notify_url")
|
||||||
|
private String notifyUrl;
|
||||||
|
@SerializedName("order_id")
|
||||||
|
private String orderId;
|
||||||
|
@SerializedName("package")
|
||||||
|
private String packageX;
|
||||||
|
@SerializedName("post_payments")
|
||||||
|
private List<PostPayment> postPayments;
|
||||||
|
@SerializedName("post_discounts")
|
||||||
|
private List<PostDiscount> postDiscounts;
|
||||||
|
@SerializedName("need_collection")
|
||||||
|
private boolean needCollection;
|
||||||
|
/**
|
||||||
|
* 收款信息
|
||||||
|
*/
|
||||||
|
@SerializedName("collection")
|
||||||
private Collection collection;
|
private Collection collection;
|
||||||
//用于跳转的sign注意区分需确认模式和无需确认模式的数据差别。创单接口会返回,查询请自行组装
|
/**
|
||||||
|
* 用于跳转的sign注意区分需确认模式和无需确认模式的数据差别。创单接口会返回,查询请自行组装
|
||||||
|
*/
|
||||||
|
@SerializedName("payScoreSignInfo")
|
||||||
private Map<String, String> payScoreSignInfo;
|
private Map<String, String> payScoreSignInfo;
|
||||||
|
|
||||||
@NoArgsConstructor
|
/**
|
||||||
@Data
|
* 收款信息
|
||||||
public static class RiskFund {
|
*/
|
||||||
/**
|
|
||||||
* name : ESTIMATE_ORDER_COST
|
|
||||||
* amount : 10000
|
|
||||||
* description : 就餐的预估费用
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private int amount;
|
|
||||||
private String description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class TimeRange {
|
|
||||||
/**
|
|
||||||
* start_time : 20091225091010
|
|
||||||
* end_time : 20091225121010
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String start_time;
|
|
||||||
private String end_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class Location {
|
|
||||||
/**
|
|
||||||
* start_location : 嗨客时尚主题展餐厅
|
|
||||||
* end_location : 嗨客时尚主题展餐厅
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String start_location;
|
|
||||||
private String end_location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class PostPayments {
|
|
||||||
/**
|
|
||||||
* name : 就餐费用服务费
|
|
||||||
* amount : 4000
|
|
||||||
* description : 就餐人均100元服务费:100/小时
|
|
||||||
* count : 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private int amount;
|
|
||||||
private String description;
|
|
||||||
private int count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class PostDiscounts {
|
|
||||||
/**
|
|
||||||
* name : 满20减1元
|
|
||||||
* description : 不与其他优惠叠加
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
@Data
|
||||||
public static class Collection {
|
@NoArgsConstructor
|
||||||
|
public static class Collection implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2279516555276133086L;
|
||||||
/**
|
/**
|
||||||
* state : USER_PAID
|
* state : USER_PAID
|
||||||
* total_amount : 3900
|
* total_amount : 3900
|
||||||
@ -135,29 +94,16 @@ public class WxPayScoreResult implements Serializable {
|
|||||||
* paid_amount : 900
|
* paid_amount : 900
|
||||||
* details : [{"seq":1,"amount":900,"paid_type":"NEWTON","paid_time":"20091225091210","transaction_id":"15646546545165651651"}]
|
* details : [{"seq":1,"amount":900,"paid_type":"NEWTON","paid_time":"20091225091210","transaction_id":"15646546545165651651"}]
|
||||||
*/
|
*/
|
||||||
|
@SerializedName("state")
|
||||||
private String state;
|
private String state;
|
||||||
private int total_amount;
|
@SerializedName("total_amount")
|
||||||
private int paying_amount;
|
private int totalAmount;
|
||||||
private int paid_amount;
|
@SerializedName("paying_amount")
|
||||||
private List<Details> details;
|
private int payingAmount;
|
||||||
|
@SerializedName("paid_amount")
|
||||||
@NoArgsConstructor
|
private int paidAmount;
|
||||||
@Data
|
@SerializedName("details")
|
||||||
public static class Details {
|
private List<Detail> details;
|
||||||
/**
|
|
||||||
* seq : 1
|
|
||||||
* amount : 900
|
|
||||||
* paid_type : NEWTON
|
|
||||||
* paid_time : 20091225091210
|
|
||||||
* transaction_id : 15646546545165651651
|
|
||||||
*/
|
|
||||||
|
|
||||||
private int seq;
|
|
||||||
private int amount;
|
|
||||||
private String paid_type;
|
|
||||||
private String paid_time;
|
|
||||||
private String transaction_id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.github.binarywang.wxpay.v3.auth.WechatPay2Validator;
|
|||||||
import com.github.binarywang.wxpay.v3.util.PemUtils;
|
import com.github.binarywang.wxpay.v3.util.PemUtils;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.ssl.SSLContexts;
|
import org.apache.http.ssl.SSLContexts;
|
||||||
@ -16,6 +17,7 @@ import org.apache.http.ssl.SSLContexts;
|
|||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
@ -107,7 +109,7 @@ public class WxPayConfig {
|
|||||||
/**
|
/**
|
||||||
* apiV3 秘钥值.
|
* apiV3 秘钥值.
|
||||||
*/
|
*/
|
||||||
private String apiv3Key;
|
private String apiV3Key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apiV3 证书序列号值
|
* apiV3 证书序列号值
|
||||||
@ -125,7 +127,7 @@ public class WxPayConfig {
|
|||||||
*/
|
*/
|
||||||
private String payScoreNotifyUrl;
|
private String payScoreNotifyUrl;
|
||||||
|
|
||||||
private CloseableHttpClient apiv3HttpClient;
|
private CloseableHttpClient apiV3HttpClient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,6 +153,7 @@ public class WxPayConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回所设置的微信支付接口请求地址域名.
|
* 返回所设置的微信支付接口请求地址域名.
|
||||||
|
*
|
||||||
* @return 微信支付接口请求地址域名
|
* @return 微信支付接口请求地址域名
|
||||||
*/
|
*/
|
||||||
public String getPayBaseUrl() {
|
public String getPayBaseUrl() {
|
||||||
@ -184,10 +187,11 @@ public class WxPayConfig {
|
|||||||
String fileHasProblemMsg = "证书文件【" + this.getKeyPath() + "】有问题,请核实!";
|
String fileHasProblemMsg = "证书文件【" + this.getKeyPath() + "】有问题,请核实!";
|
||||||
String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!";
|
String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!";
|
||||||
if (this.getKeyPath().startsWith(prefix)) {
|
if (this.getKeyPath().startsWith(prefix)) {
|
||||||
String path = StringUtils.removeFirst(this.getKeyPath(), prefix);
|
String path = RegExUtils.removeFirst(this.getKeyPath(), prefix);
|
||||||
if (!path.startsWith("/")) {
|
if (!path.startsWith("/")) {
|
||||||
path = "/" + path;
|
path = "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
|
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
throw new WxPayException(fileNotFoundMsg);
|
throw new WxPayException(fileNotFoundMsg);
|
||||||
@ -230,18 +234,17 @@ public class WxPayConfig {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author doger.wang
|
* 初始化api v3请求头 自动签名验签
|
||||||
* @Description 初始化api v3请求头 自动签名验签
|
|
||||||
* 方法参照微信官方https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient
|
* 方法参照微信官方https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient
|
||||||
* @Date 2020/5/14 10:10
|
*
|
||||||
* @Param []
|
|
||||||
* @return org.apache.http.impl.client.CloseableHttpClient
|
* @return org.apache.http.impl.client.CloseableHttpClient
|
||||||
|
* @author doger.wang
|
||||||
**/
|
**/
|
||||||
public CloseableHttpClient initApiV3HttpClient()throws WxPayException {
|
public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
|
||||||
String privateKeyPath = this.getPrivateKeyPath();
|
String privateKeyPath = this.getPrivateKeyPath();
|
||||||
String privateCertPath = this.getPrivateCertPath();
|
String privateCertPath = this.getPrivateCertPath();
|
||||||
String certSerialNo = this.getCertSerialNo();
|
String certSerialNo = this.getCertSerialNo();
|
||||||
String apiv3Key = this.getApiv3Key();
|
String apiV3Key = this.getApiV3Key();
|
||||||
if (StringUtils.isBlank(privateKeyPath)) {
|
if (StringUtils.isBlank(privateKeyPath)) {
|
||||||
throw new WxPayException("请确保privateKeyPath已设置");
|
throw new WxPayException("请确保privateKeyPath已设置");
|
||||||
}
|
}
|
||||||
@ -251,55 +254,55 @@ public class WxPayConfig {
|
|||||||
if (StringUtils.isBlank(certSerialNo)) {
|
if (StringUtils.isBlank(certSerialNo)) {
|
||||||
throw new WxPayException("请确保certSerialNo证书序列号已设置");
|
throw new WxPayException("请确保certSerialNo证书序列号已设置");
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(apiv3Key)) {
|
if (StringUtils.isBlank(apiV3Key)) {
|
||||||
throw new WxPayException("请确保apiv3Key值已设置");
|
throw new WxPayException("请确保apiV3Key值已设置");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputStream keyInputStream = null;
|
||||||
InputStream keyinputStream=null;
|
InputStream certInputStream = null;
|
||||||
InputStream certinputStream=null;
|
|
||||||
final String prefix = "classpath:";
|
final String prefix = "classpath:";
|
||||||
if (privateKeyPath.startsWith(prefix)) {
|
if (privateKeyPath.startsWith(prefix)) {
|
||||||
String keypath = StringUtils.removeFirst(privateKeyPath, prefix);
|
String keypath = RegExUtils.removeFirst(privateKeyPath, prefix);
|
||||||
if (!keypath.startsWith("/")) {
|
if (!keypath.startsWith("/")) {
|
||||||
keypath = "/" + keypath;
|
keypath = "/" + keypath;
|
||||||
}
|
}
|
||||||
keyinputStream = WxPayConfig.class.getResourceAsStream(keypath);
|
keyInputStream = WxPayConfig.class.getResourceAsStream(keypath);
|
||||||
if (keyinputStream == null) {
|
if (keyInputStream == null) {
|
||||||
throw new WxPayException("证书文件【" + this.getPrivateKeyPath() + "】不存在,请核实!");
|
throw new WxPayException("证书文件【" + this.getPrivateKeyPath() + "】不存在,请核实!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privateCertPath.startsWith(prefix)) {
|
if (privateCertPath.startsWith(prefix)) {
|
||||||
String certpath = StringUtils.removeFirst(privateCertPath, prefix);
|
String certpath = RegExUtils.removeFirst(privateCertPath, prefix);
|
||||||
if (!certpath.startsWith("/")) {
|
if (!certpath.startsWith("/")) {
|
||||||
certpath = "/" + certpath;
|
certpath = "/" + certpath;
|
||||||
}
|
}
|
||||||
certinputStream = WxPayConfig.class.getResourceAsStream(certpath);
|
certInputStream = WxPayConfig.class.getResourceAsStream(certpath);
|
||||||
if (certinputStream == null) {
|
if (certInputStream == null) {
|
||||||
throw new WxPayException("证书文件【" + this.getPrivateCertPath() + "】不存在,请核实!");
|
throw new WxPayException("证书文件【" + this.getPrivateCertPath() + "】不存在,请核实!");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CloseableHttpClient httpClient = null;
|
|
||||||
try {
|
|
||||||
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create();
|
|
||||||
PrivateKey merchantPrivateKey = PemUtils.loadPrivateKey(keyinputStream);
|
|
||||||
X509Certificate x509Certificate = PemUtils.loadCertificate(certinputStream);
|
|
||||||
ArrayList<X509Certificate> certificates = new ArrayList<>();
|
|
||||||
certificates.add(x509Certificate);
|
|
||||||
builder.withMerchant(mchId, certSerialNo, merchantPrivateKey);
|
|
||||||
builder.withWechatpay(certificates);
|
|
||||||
AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
|
|
||||||
new WechatPay2Credentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
|
||||||
apiv3Key.getBytes("utf-8"));
|
|
||||||
builder.withValidator(new WechatPay2Validator(verifier));
|
|
||||||
httpClient = builder.build();
|
|
||||||
this.apiv3HttpClient =httpClient;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new WxPayException("v3请求构造异常", e);
|
|
||||||
}
|
|
||||||
return httpClient;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CloseableHttpClient httpClient;
|
||||||
|
try {
|
||||||
|
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create();
|
||||||
|
PrivateKey merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);
|
||||||
|
X509Certificate x509Certificate = PemUtils.loadCertificate(certInputStream);
|
||||||
|
ArrayList<X509Certificate> certificates = new ArrayList<>();
|
||||||
|
certificates.add(x509Certificate);
|
||||||
|
builder.withMerchant(mchId, certSerialNo, merchantPrivateKey);
|
||||||
|
builder.withWechatpay(certificates);
|
||||||
|
AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
|
||||||
|
new WechatPay2Credentials(mchId, new PrivateKeySigner(certSerialNo, merchantPrivateKey)),
|
||||||
|
apiV3Key.getBytes(StandardCharsets.UTF_8));
|
||||||
|
builder.withValidator(new WechatPay2Validator(verifier));
|
||||||
|
httpClient = builder.build();
|
||||||
|
this.apiV3HttpClient = httpClient;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new WxPayException("v3请求构造异常!", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.service;
|
package com.github.binarywang.wxpay.service;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.payscore.NotifyData;
|
import com.github.binarywang.wxpay.bean.payscore.PayScoreNotifyData;
|
||||||
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreRequest;
|
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreRequest;
|
||||||
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult;
|
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
@ -11,154 +11,120 @@ import java.net.URISyntaxException;
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 支付分相关服务类.
|
* 支付分相关服务类.
|
||||||
* 微信支付分是对个人的身份特质、支付行为、使用历史等情况的综合计算分值,旨在为用户提供更简单便捷的生活方式。
|
* 微信支付分是对个人的身份特质、支付行为、使用历史等情况的综合计算分值,旨在为用户提供更简单便捷的生活方式。
|
||||||
* 微信用户可以在具体应用场景中,开通微信支付分。开通后,用户可以在【微信—>钱包—>支付分】中查看分数和使用记录。(即需在应用场景中使用过一次,钱包才会出现支付分入口)
|
* 微信用户可以在具体应用场景中,开通微信支付分。开通后,用户可以在【微信—>钱包—>支付分】中查看分数和使用记录。
|
||||||
|
* (即需在应用场景中使用过一次,钱包才会出现支付分入口)
|
||||||
*
|
*
|
||||||
* Created by doger.wang on 2020/05/12.
|
* Created by doger.wang on 2020/05/12.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
*
|
* @author doger.wang
|
||||||
*/
|
*/
|
||||||
public interface PayScoreService {
|
public interface PayScoreService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分创建订单API.
|
* 支付分创建订单API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter1_1.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_1.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_1.shtml
|
* 接口链接:https://api.mch.weixin.qq.com/v3/payscore/serviceorder
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param request 请求对象
|
* @param request 请求对象
|
||||||
* @return WxPayScoreResult
|
* @return WxPayScoreResult wx pay score result
|
||||||
* @throws WxPayException the wx pay exception
|
* @throws WxPayException the wx pay exception
|
||||||
*/
|
*/
|
||||||
WxPayScoreResult createServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
WxPayScoreResult createServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分查询订单API.
|
* 支付分查询订单API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_2.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_2.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_2.shtml
|
* 接口链接:https://api.mch.weixin.qq.com/v3/payscore/serviceorder
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param outOrderNo the out order no
|
||||||
* @Description
|
* @param queryId the query id
|
||||||
* @Date 2020/5/14 15:40
|
* @return the wx pay score result
|
||||||
* @Param out_order_no, query_id选填一个
|
* @throws WxPayException the wx pay exception
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
* @throws URISyntaxException the uri syntax exception
|
||||||
**/
|
*/
|
||||||
WxPayScoreResult queryServiceOrder( String out_order_no,String query_id ) throws WxPayException, URISyntaxException;
|
WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException, URISyntaxException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分取消订单API.
|
* 支付分取消订单API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_3.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_3.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_3.shtml
|
* 接口链接:https://api.mch.weixin.qq.com/v3/payscore/serviceorder/{out_order_no}/cancel
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param outOrderNo the out order no
|
||||||
* @Description
|
* @param reason the reason
|
||||||
* @Date 2020/5/14 15:40
|
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult wx pay score result
|
||||||
* @Param out_order_no reason
|
* @throws WxPayException the wx pay exception
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
*/
|
||||||
**/
|
WxPayScoreResult cancelServiceOrder(String outOrderNo, String reason) throws WxPayException;
|
||||||
WxPayScoreResult cancelServiceOrder(String out_order_no, String reason) throws WxPayException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分修改订单金额API.
|
* 支付分修改订单金额API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_4.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_4.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_4.shtml
|
* 接口链接:https://api.mch.weixin.qq.com/v3/payscore/serviceorder/{out_order_no}/modify
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param request the request
|
||||||
* @Description
|
* @return the wx pay score result
|
||||||
* @Date 2020/5/14 15:40
|
* @throws WxPayException the wx pay exception
|
||||||
* @Param WxPayScoreRequest
|
*/
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
|
||||||
**/
|
|
||||||
WxPayScoreResult modifyServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
WxPayScoreResult modifyServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分完结订单API.
|
* 支付分完结订单API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_5.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_5.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_5.shtml
|
* 请求URL:https://api.mch.weixin.qq.com/v3/payscore/serviceorder/{out_order_no}/complete
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param request the request
|
||||||
* @Description
|
* @return the wx pay score result
|
||||||
* @Date 2020/5/14 15:40
|
* @throws WxPayException the wx pay exception
|
||||||
* @Param WxPayScoreRequest
|
*/
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
|
||||||
**/
|
|
||||||
WxPayScoreResult completeServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
WxPayScoreResult completeServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分订单收款API.
|
* 支付分订单收款API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_6.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_6.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_6.shtml
|
* 请求URL:https://api.mch.weixin.qq.com/v3/payscore/serviceorder/{out_order_no}/pay
|
||||||
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param outOrderNo the out order no
|
||||||
* @Description
|
* @return the wx pay score result
|
||||||
* @Date 2020/5/14 15:40
|
* @throws WxPayException the wx pay exception
|
||||||
* @Param out_order_no
|
*/
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
WxPayScoreResult payServiceOrder(String outOrderNo) throws WxPayException;
|
||||||
**/
|
|
||||||
WxPayScoreResult payServiceOrder(String out_order_no) throws WxPayException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分订单收款API.
|
* 支付分订单收款API.
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_7.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_7.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter3_7.shtml
|
* 请求URL: https://api.mch.weixin.qq.com/v3/payscore/serviceorder/{out_order_no}/sync
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @Author doger.wang
|
* @param request the request
|
||||||
* @Description
|
* @return the wx pay score result
|
||||||
* @Date 2020/5/14 15:40
|
* @throws WxPayException the wx pay exception
|
||||||
* @Param WxPayScoreRequest
|
*/
|
||||||
* @return com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult
|
|
||||||
**/
|
|
||||||
WxPayScoreResult syncServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
WxPayScoreResult syncServiceOrder(WxPayScoreRequest request) throws WxPayException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 支付分回调内容解密方法
|
* 支付分回调内容解析方法
|
||||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter5_2.shtml
|
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter5_2.shtml
|
||||||
* 接口链接:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter5_2.shtml
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param NotifyData 请求对象
|
* @param data the data
|
||||||
* @return WxPayScoreResult
|
* @return the wx pay score result
|
||||||
|
* @throws WxPayException the wx pay exception
|
||||||
*/
|
*/
|
||||||
WxPayScoreResult decryptNotifyData(NotifyData data) throws WxPayException;
|
WxPayScoreResult parseNotifyData(PayScoreNotifyData data) throws WxPayException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.service.impl;
|
package com.github.binarywang.wxpay.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.github.binarywang.wxpay.bean.payscore.PayScoreNotifyData;
|
||||||
import com.github.binarywang.wxpay.bean.payscore.NotifyData;
|
|
||||||
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreRequest;
|
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreRequest;
|
||||||
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult;
|
import com.github.binarywang.wxpay.bean.payscore.WxPayScoreResult;
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||||
@ -9,11 +8,13 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|||||||
import com.github.binarywang.wxpay.service.PayScoreService;
|
import com.github.binarywang.wxpay.service.PayScoreService;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.github.binarywang.wxpay.v3.util.AesUtils;
|
import com.github.binarywang.wxpay.v3.util.AesUtils;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -23,35 +24,31 @@ import java.util.Map;
|
|||||||
* @author doger.wang
|
* @author doger.wang
|
||||||
* @date 2020/5/14 9:43
|
* @date 2020/5/14 9:43
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class PayScoreServiceImpl implements PayScoreService {
|
public class PayScoreServiceImpl implements PayScoreService {
|
||||||
private WxPayService payService;
|
private static final Gson GSON = new GsonBuilder().create();
|
||||||
|
private final WxPayService payService;
|
||||||
public PayScoreServiceImpl(WxPayService payService) {
|
|
||||||
this.payService = payService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult createServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
public WxPayScoreResult createServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
||||||
boolean need_user_confirm = request.isNeed_user_confirm();
|
boolean needUserConfirm = request.isNeedUserConfirm();
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
||||||
request.setAppid(config.getAppId());
|
request.setAppid(config.getAppId());
|
||||||
request.setService_id(config.getServiceId());
|
request.setServiceId(config.getServiceId());
|
||||||
request.setNotify_url(config.getPayScoreNotifyUrl());
|
request.setNotifyUrl(config.getPayScoreNotifyUrl());
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(request));
|
String result = payService.postV3(url, GSON.toJson(request));
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
WxPayScoreResult wxPayScoreCreateResult = GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
|
|
||||||
//补充算一下签名给小程序跳转用
|
//补充算一下签名给小程序跳转用
|
||||||
String currentTimeMillis = System.currentTimeMillis() + "";
|
String currentTimeMillis = System.currentTimeMillis() + "";
|
||||||
Map<String, String> signMap = new HashMap<>();
|
Map<String, String> signMap = new HashMap<>(8);
|
||||||
signMap.put("mch_id", config.getMchId());
|
signMap.put("mch_id", config.getMchId());
|
||||||
if (need_user_confirm){
|
if (needUserConfirm) {
|
||||||
signMap.put("package", wxPayScoreCreateResult.getPackageX());
|
signMap.put("package", wxPayScoreCreateResult.getPackageX());
|
||||||
}else {
|
} else {
|
||||||
signMap.put("service_id", config.getServiceId());
|
signMap.put("service_id", config.getServiceId());
|
||||||
signMap.put("out_order_no", request.getOut_order_no());
|
signMap.put("out_order_no", request.getOutOrderNo());
|
||||||
}
|
}
|
||||||
signMap.put("timestamp", currentTimeMillis);
|
signMap.put("timestamp", currentTimeMillis);
|
||||||
signMap.put("nonce_str", currentTimeMillis);
|
signMap.put("nonce_str", currentTimeMillis);
|
||||||
@ -63,131 +60,96 @@ public class PayScoreServiceImpl implements PayScoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult queryServiceOrder(String out_order_no, String query_id) throws WxPayException, URISyntaxException {
|
public WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException, URISyntaxException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
||||||
URIBuilder uriBuilder = new URIBuilder(url);
|
URIBuilder uriBuilder = new URIBuilder(url);
|
||||||
if (StringUtils.isAllEmpty(out_order_no,query_id) || !StringUtils.isAnyEmpty(out_order_no,query_id)){
|
if (StringUtils.isAllEmpty(outOrderNo, queryId) || !StringUtils.isAnyEmpty(outOrderNo, queryId)) {
|
||||||
throw new WxPayException("out_order_no,query_id不允许都填写或都不填写");
|
throw new WxPayException("out_order_no,query_id不允许都填写或都不填写");
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(out_order_no)){
|
if (StringUtils.isNotEmpty(outOrderNo)) {
|
||||||
uriBuilder.setParameter("out_order_no", out_order_no);
|
uriBuilder.setParameter("out_order_no", outOrderNo);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(query_id)){
|
if (StringUtils.isNotEmpty(queryId)) {
|
||||||
uriBuilder.setParameter("query_id", query_id);
|
uriBuilder.setParameter("query_id", queryId);
|
||||||
}
|
}
|
||||||
uriBuilder.setParameter("service_id", config.getServiceId());
|
uriBuilder.setParameter("service_id", config.getServiceId());
|
||||||
uriBuilder.setParameter("appid", config.getAppId());
|
uriBuilder.setParameter("appid", config.getAppId());
|
||||||
URI build = uriBuilder.build();
|
String result = payService.getV3(uriBuilder.build());
|
||||||
String result = payService.getV3(build);
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
|
||||||
//补充一下加密跳转信息
|
|
||||||
/* String currentTimeMillis = System.currentTimeMillis() + "";
|
|
||||||
Map<String, String> signMap = new HashMap();
|
|
||||||
signMap.put("mch_id", config.getMchId());
|
|
||||||
signMap.put("service_id", config.getServiceId());
|
|
||||||
signMap.put("out_order_no", out_order_no);
|
|
||||||
signMap.put("timestamp", currentTimeMillis);
|
|
||||||
signMap.put("nonce_str", currentTimeMillis);
|
|
||||||
signMap.put("sign_type", "HMAC-SHA256");
|
|
||||||
String sign = AesUtil.createSign(signMap, config.getMchKey());
|
|
||||||
signMap.put("sign", sign);
|
|
||||||
wxPayScoreCreateResult.setPayScoreSignInfo(signMap);*/
|
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult cancelServiceOrder(String out_order_no, String reason) throws WxPayException {
|
public WxPayScoreResult cancelServiceOrder(String outOrderNo, String reason) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder/"+out_order_no+"/cancel";
|
String url = String.format("%s/v3/payscore/serviceorder/%s/cancel", this.payService.getPayBaseUrl(), outOrderNo);
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>(4);
|
||||||
map.put("appid",config.getAppId());
|
map.put("appid", config.getAppId());
|
||||||
map.put("service_id",config.getServiceId());
|
map.put("service_id", config.getServiceId());
|
||||||
map.put("reason",reason);
|
map.put("reason", reason);
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(map));
|
String result = payService.postV3(url, GSON.toJson(map));
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult modifyServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
public WxPayScoreResult modifyServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String out_order_no = request.getOut_order_no();
|
String outOrderNo = request.getOutOrderNo();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder/"+out_order_no+"/modify";
|
String url = String.format("%s/v3/payscore/serviceorder/%s/modify", this.payService.getPayBaseUrl(), outOrderNo);
|
||||||
request.setAppid(config.getAppId());
|
request.setAppid(config.getAppId());
|
||||||
request.setService_id(config.getServiceId());
|
request.setServiceId(config.getServiceId());
|
||||||
request.setOut_order_no(null);
|
request.setOutOrderNo(null);
|
||||||
//request.setNotify_url(config.getPayScoreNotifyUrl());
|
String result = payService.postV3(url, GSON.toJson(request));
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(request));
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult completeServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
public WxPayScoreResult completeServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String out_order_no = request.getOut_order_no();
|
String outOrderNo = request.getOutOrderNo();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder/"+out_order_no+"/complete";
|
String url = String.format("%s/v3/payscore/serviceorder/%s/complete", this.payService.getPayBaseUrl(), outOrderNo);
|
||||||
request.setAppid(config.getAppId());
|
request.setAppid(config.getAppId());
|
||||||
request.setService_id(config.getServiceId());
|
request.setServiceId(config.getServiceId());
|
||||||
//request.setNotify_url(config.getPayScoreNotifyUrl());
|
request.setOutOrderNo(null);
|
||||||
request.setOut_order_no(null);
|
String result = payService.postV3(url, GSON.toJson(request));
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(request));
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult payServiceOrder(String out_order_no) throws WxPayException {
|
public WxPayScoreResult payServiceOrder(String outOrderNo) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder/"+out_order_no+"/pay";
|
String url = String.format("%s/v3/payscore/serviceorder/%s/pay", this.payService.getPayBaseUrl(), outOrderNo);
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>(2);
|
||||||
map.put("appid",config.getAppId());
|
map.put("appid", config.getAppId());
|
||||||
map.put("service_id",config.getServiceId());
|
map.put("service_id", config.getServiceId());
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(map));
|
String result = payService.postV3(url, GSON.toJson(map));
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult syncServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
public WxPayScoreResult syncServiceOrder(WxPayScoreRequest request) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String out_order_no = request.getOut_order_no();
|
String outOrderNo = request.getOutOrderNo();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder/"+out_order_no+"/sync";
|
String url = String.format("%s/v3/payscore/serviceorder/%s/sync", this.payService.getPayBaseUrl(), outOrderNo);
|
||||||
request.setAppid(config.getAppId());
|
request.setAppid(config.getAppId());
|
||||||
request.setService_id(config.getServiceId());
|
request.setServiceId(config.getServiceId());
|
||||||
request.setOut_order_no(null);
|
request.setOutOrderNo(null);
|
||||||
//request.setNotify_url(config.getPayScoreNotifyUrl());
|
String result = payService.postV3(url, GSON.toJson(request));
|
||||||
String result = payService.postV3(url, JSONObject.toJSONString(request));
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(result, WxPayScoreResult.class);
|
|
||||||
return wxPayScoreCreateResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult decryptNotifyData(NotifyData data) throws WxPayException{
|
public WxPayScoreResult parseNotifyData(PayScoreNotifyData data) throws WxPayException {
|
||||||
NotifyData.Resource resource = data.getResource();
|
PayScoreNotifyData.Resource resource = data.getResource();
|
||||||
String ciphertext = resource.getCiphertext();
|
String cipherText = resource.getCipherText();
|
||||||
String associated_data = resource.getAssociated_data();
|
String associatedData = resource.getAssociatedData();
|
||||||
String nonce = resource.getNonce();
|
String nonce = resource.getNonce();
|
||||||
String apiv3Key = this.payService.getConfig().getApiv3Key();
|
String apiV3Key = this.payService.getConfig().getApiV3Key();
|
||||||
try {
|
try {
|
||||||
String s = AesUtils.decryptToString(associated_data, nonce, ciphertext, apiv3Key);
|
String s = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
|
||||||
WxPayScoreResult wxPayScoreCreateResult = JSONObject.parseObject(s, WxPayScoreResult.class);
|
return GSON.fromJson(s, WxPayScoreResult.class);
|
||||||
return wxPayScoreCreateResult;
|
} catch (GeneralSecurityException | IOException e) {
|
||||||
} catch (GeneralSecurityException e) {
|
throw new WxPayException("解析报文异常!", e);
|
||||||
throw new WxPayException("解析报文异常",e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new WxPayException("解析报文异常",e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
package com.github.binarywang.wxpay.service.impl;
|
package com.github.binarywang.wxpay.service.impl;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.github.binarywang.wxpay.bean.WxPayApiData;
|
import com.github.binarywang.wxpay.bean.WxPayApiData;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayQueryCommentRequest;
|
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayRedpackQueryRequest;
|
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayCommonResult;
|
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import jodd.util.Base64;
|
import jodd.util.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -35,10 +28,6 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.WxPayApiData;
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
||||||
import jodd.util.Base64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 微信支付请求实现类,apache httpclient实现.
|
* 微信支付请求实现类,apache httpclient实现.
|
||||||
@ -158,7 +147,7 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CloseableHttpClient createApiV3HttpClient() throws WxPayException {
|
private CloseableHttpClient createApiV3HttpClient() throws WxPayException {
|
||||||
CloseableHttpClient apiv3HttpClient = this.getConfig().getApiv3HttpClient();
|
CloseableHttpClient apiv3HttpClient = this.getConfig().getApiV3HttpClient();
|
||||||
if (null==apiv3HttpClient){
|
if (null==apiv3HttpClient){
|
||||||
return this.getConfig().initApiV3HttpClient();
|
return this.getConfig().initApiV3HttpClient();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.github.binarywang.wxpay.service.impl;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试代码,待补充完善.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* @date 2020-05-19
|
||||||
|
*/
|
||||||
|
public class PayScoreServiceImplTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testQueryServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCancelServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModifyServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompleteServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPayServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSyncServiceOrder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecryptNotifyData() {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user