|
|
|
@@ -148,7 +148,7 @@ public class PosAppTest { |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void checkCouponOrderForVerifyTest() throws Exception { |
|
|
|
public void checkCouponOrderForIndeepdentVerifyTest() throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, "456"); |
|
|
|
@@ -156,6 +156,35 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, "317111133332426752"); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744"); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.VERIFY_TYPE, "independent"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void checkCouponOrderForPayVerifyTest() throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, "456"); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, "317109453987631104"); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, "317111133332426752"); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744"); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.VERIFY_TYPE, "pay"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
|