mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 18:46:10 +08:00 
			
		
		
		
	🎨 微信支付分支付回调接口优化以及补充测试代码
This commit is contained in:
		| @ -125,6 +125,19 @@ public interface PayScoreService { | |||||||
|    * @return the wx pay score result |    * @return the wx pay score result | ||||||
|    * @throws WxPayException the wx pay exception |    * @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; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -139,7 +139,13 @@ public class PayScoreServiceImpl implements PayScoreService { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @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(); |     PayScoreNotifyData.Resource resource = data.getResource(); | ||||||
|     String cipherText = resource.getCipherText(); |     String cipherText = resource.getCipherText(); | ||||||
|     String associatedData = resource.getAssociatedData(); |     String associatedData = resource.getAssociatedData(); | ||||||
|  | |||||||
| @ -21,16 +21,55 @@ public class PayScoreServiceImplTest { | |||||||
|   private WxPayService payService; |   private WxPayService payService; | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|  |  | ||||||
|   public void testCreateServiceOrder() throws WxPayException { |   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()); |     this.payService.getPayScoreService().createServiceOrder(WxPayScoreRequest.builder().build()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|   public void testQueryServiceOrder() { |   public void testQueryServiceOrder() { | ||||||
|  |     //两个参数选填一个 | ||||||
|  |     this.payService.getPayScoreService().queryServiceOrder("11",""); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|   public void testCancelServiceOrder() { |   public void testCancelServiceOrder() { | ||||||
|  |     this.payService.getPayScoreService().cancelServiceOrder("11","测试取消"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
| @ -38,8 +77,27 @@ public class PayScoreServiceImplTest { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test |   @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 |   @Test | ||||||
|   public void testPayServiceOrder() { |   public void testPayServiceOrder() { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 spvycf
					spvycf