Browse Source

🎨 微信支付分支付回调接口优化以及补充测试代码

dev1
spvycf 4 years ago
committed by GitHub
parent
commit
50e50c13c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 4 deletions
  1. +14
    -1
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java
  2. +7
    -1
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java
  3. +60
    -2
      weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java

+ 14
- 1
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java View File

@@ -125,6 +125,19 @@ public interface PayScoreService {
* @return the wx pay score result
* @throws WxPayException the wx pay exception
*/
WxPayScoreResult parseNotifyData(PayScoreNotifyData data) throws WxPayException;
PayScoreNotifyData parseNotifyData(String data);


/**
* <pre>
* 支付分回调NotifyData解密resource
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter5_2.shtml
* </pre>
*
* @param data the data
* @return the wx pay score result
* @throws WxPayException the wx pay exception
*/
WxPayScoreResult decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException;

}

+ 7
- 1
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java View File

@@ -139,7 +139,13 @@ public class PayScoreServiceImpl implements PayScoreService {
}

@Override
public WxPayScoreResult parseNotifyData(PayScoreNotifyData data) throws WxPayException {
public PayScoreNotifyData parseNotifyData(String data){
return GSON.fromJson(data, PayScoreNotifyData.class);

}

@Override
public WxPayScoreResult decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException {
PayScoreNotifyData.Resource resource = data.getResource();
String cipherText = resource.getCipherText();
String associatedData = resource.getAssociatedData();


+ 60
- 2
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java View File

@@ -21,16 +21,55 @@ public class PayScoreServiceImplTest {
private WxPayService payService;

@Test

public void testCreateServiceOrder() throws WxPayException {
//测试数据
/* {
"out_order_no":"QLS202005201058000201",
"appid":"",
"service_id":"",
"service_introduction":"租借服务",
"time_range":{
"start_time":"OnAccept",
"end_time":"20200520225840"
},
"location":{
"start_location":"山",
"end_location":"山"
},
"risk_fund":{
"name":"DEPOSIT",
"amount":200,
"description":"丢失偿还费用2元/台"
},
"attach":"",
"notify_url":"/pay/notify/payScore",
"openid":"",
"need_user_confirm":true,
"profit_sharing":false,
"post_payments":[
{
"name":"租借服务",
"amount":100,
"description":"服务费:1元/台",
"count":1
}
],
"total_amount":0
}*/

this.payService.getPayScoreService().createServiceOrder(WxPayScoreRequest.builder().build());
}

@Test
public void testQueryServiceOrder() {
//两个参数选填一个
this.payService.getPayScoreService().queryServiceOrder("11","");
}

@Test
public void testCancelServiceOrder() {
this.payService.getPayScoreService().cancelServiceOrder("11","测试取消");
}

@Test
@@ -38,8 +77,27 @@ public class PayScoreServiceImplTest {
}

@Test
public void testCompleteServiceOrder() {
}
public void testCompleteServiceOrder() throws WxPayException{
/* {
"appid":"",
"service_id":"",
"time_range":{
"end_time":"20200520111702"
},
"need_user_confirm":false,
"profit_sharing":false,
"post_payments":[
{
"name":"租借服务",
"amount":100,
"description":"服务费:1.0000元/台",
"count":1
}
],
"total_amount":100
}
}*/
this.payService.getPayScoreService().completeServiceOrder(WxPayScoreRequest.builder().build());

@Test
public void testPayServiceOrder() {


Loading…
Cancel
Save