|
|
|
@@ -99,6 +99,7 @@ public class PosAppTest { |
|
|
|
@Test |
|
|
|
public void getPosMemConfigTest() throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
@@ -121,6 +122,7 @@ public class PosAppTest { |
|
|
|
@Test |
|
|
|
public void getQrCodeTest() throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
@@ -211,8 +213,25 @@ public class PosAppTest { |
|
|
|
doPayVerifyList(couponOrderIdList, posOrderId, posAmount); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void cardPayPreTest() throws Exception { |
|
|
|
String cardId = "321883878446825472"; |
|
|
|
String posOrderId = "1"; |
|
|
|
String posAmount = "200"; |
|
|
|
doCardPayPre(cardId, posOrderId, posAmount); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void cardPayPreCancelTest() throws Exception { |
|
|
|
String cardId = "321883878446825472"; |
|
|
|
String posOrderId = "1"; |
|
|
|
String cardSpendId = "1"; |
|
|
|
doCardPayPreCancel(cardId, cardSpendId, posOrderId); |
|
|
|
} |
|
|
|
|
|
|
|
private void doCheckMem(String memId, String phone, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
@@ -242,12 +261,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doCheckVerify(String couponOrderId, String verifyType, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.VERIFY_TYPE, verifyType); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
@@ -269,12 +288,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doIndependentVerify(String couponOrderId, String posOrderId) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
@@ -295,12 +314,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doVerifyCancel(String couponOrderId, String posOrderId) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
@@ -320,12 +339,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doPreVerify(String couponOrderId, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
@@ -347,12 +366,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doPreVerifyCancel(String couponOrderId, String posOrderId) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
@@ -372,12 +391,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doPayVerifyOne(String couponOrderId, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
@@ -398,12 +417,12 @@ public class PosAppTest { |
|
|
|
|
|
|
|
private void doPayVerifyList(String couponOrderIdList, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.SELECTED_COUPON_ORDER_LIST, couponOrderIdList); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
@@ -421,4 +440,110 @@ public class PosAppTest { |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
private void doCardPayPre(String cardId, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
reqObj.put(WxPayConstant.CARD_ID, cardId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/cardPayPre") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void doCardPayPreCancel(String cardId, String cardSpendId, String posOrderId) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.CARD_ID, cardId); |
|
|
|
reqObj.put(WxPayConstant.CARD_SPEND_ID, cardSpendId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/cardPayPreCancel") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
private void doCardPay(String cardId, String posOrderId, String posAmount) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
reqObj.put(WxPayConstant.CARD_ID, cardId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/cardPay") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void doCardPayCancel(String cardId, String cardSpendId, String posOrderId) throws Exception { |
|
|
|
Map<String, String> reqObj = new HashMap<>(); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.DEV_ID, devId); |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
reqObj.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
reqObj.put(WxPayConstant.CARD_ID, cardId); |
|
|
|
reqObj.put(WxPayConstant.CARD_SPEND_ID, cardSpendId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/cardPayCancel") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
} |