From 50e50c13c4bd8972c4cc23b67e3b8bece722794d Mon Sep 17 00:00:00 2001 From: spvycf <545997765@qq.com> Date: Thu, 21 May 2020 21:18:59 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=88=86=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A5=E5=8F=8A=E8=A1=A5=E5=85=85=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/service/PayScoreService.java | 15 ++++- .../service/impl/PayScoreServiceImpl.java | 8 ++- .../service/impl/PayScoreServiceImplTest.java | 62 ++++++++++++++++++- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java index dafa474be..079f1e7ca 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PayScoreService.java @@ -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); + + + /** + *
+ * 支付分回调NotifyData解密resource + * 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/payscore/chapter5_2.shtml + *+ * + * @param data the data + * @return the wx pay score result + * @throws WxPayException the wx pay exception + */ + WxPayScoreResult decryptNotifyDataResource(PayScoreNotifyData data) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java index 79b64fb3f..299e8f87d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImpl.java @@ -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(); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java index b10871b87..fd805b6fc 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PayScoreServiceImplTest.java @@ -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() {