|
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
class OmgPaymentFormFactoryTest {
|
|
class OmgPaymentFormFactoryTest {
|
|
|
@Test
|
|
@Test
|
|
|
- void buildsExactStageOnlySignedForm() {
|
|
|
|
|
|
|
+ void buildsSignedFormThatOnlyOffersCreditAndApplePay() {
|
|
|
OmgPaymentProperties properties = properties();
|
|
OmgPaymentProperties properties = properties();
|
|
|
OmgCheckMacSigner signer = mock(OmgCheckMacSigner.class);
|
|
OmgCheckMacSigner signer = mock(OmgCheckMacSigner.class);
|
|
|
when(signer.sign(anyMap(), eq("KEY"), eq("IV"))).thenReturn("A".repeat(64));
|
|
when(signer.sign(anyMap(), eq("KEY"), eq("IV"))).thenReturn("A".repeat(64));
|
|
@@ -34,22 +34,26 @@ class OmgPaymentFormFactoryTest {
|
|
|
assertEquals(OmgPaymentFormFactory.STAGE_GATEWAY_URL, form.gatewayUrl());
|
|
assertEquals(OmgPaymentFormFactory.STAGE_GATEWAY_URL, form.gatewayUrl());
|
|
|
assertEquals(Set.of("MerchantID", "MerchantTradeNo", "MerchantTradeDate", "PaymentType",
|
|
assertEquals(Set.of("MerchantID", "MerchantTradeNo", "MerchantTradeDate", "PaymentType",
|
|
|
"TotalAmount", "TradeDesc", "ItemName", "ReturnURL", "ChoosePayment", "EncryptType",
|
|
"TotalAmount", "TradeDesc", "ItemName", "ReturnURL", "ChoosePayment", "EncryptType",
|
|
|
- "InvoiceMark", "NeedExtraPaidInfo", "ExpireDate", "StoreExpireDate",
|
|
|
|
|
- "BarcodeATMExpireDate", "OrderResultURL", "ClientRedirectURL", "ClientBackURL",
|
|
|
|
|
|
|
+ "InvoiceMark", "NeedExtraPaidInfo", "UnionPay", "OrderResultURL", "ClientBackURL",
|
|
|
"CheckMacValue"), form.fields().keySet());
|
|
"CheckMacValue"), form.fields().keySet());
|
|
|
assertEquals("2026/08/13 15:30:23", form.fields().get("MerchantTradeDate"));
|
|
assertEquals("2026/08/13 15:30:23", form.fields().get("MerchantTradeDate"));
|
|
|
- assertEquals("ALL", form.fields().get("ChoosePayment"));
|
|
|
|
|
|
|
+ assertEquals("Credit", form.fields().get("ChoosePayment"));
|
|
|
|
|
+ assertEquals("2", form.fields().get("UnionPay"));
|
|
|
assertEquals("Y", form.fields().get("NeedExtraPaidInfo"));
|
|
assertEquals("Y", form.fields().get("NeedExtraPaidInfo"));
|
|
|
assertEquals("https://foodieapi.waimai-paotui.com/pay/omg/result",
|
|
assertEquals("https://foodieapi.waimai-paotui.com/pay/omg/result",
|
|
|
form.fields().get("OrderResultURL"));
|
|
form.fields().get("OrderResultURL"));
|
|
|
- assertEquals("https://foodieapi.waimai-paotui.com/pay/omg/payment-info-result",
|
|
|
|
|
- form.fields().get("ClientRedirectURL"));
|
|
|
|
|
assertEquals("https://foodieapi.waimai-paotui.com/pay/omg/back?merchantTradeNo=OMG12345678901234567",
|
|
assertEquals("https://foodieapi.waimai-paotui.com/pay/omg/back?merchantTradeNo=OMG12345678901234567",
|
|
|
form.fields().get("ClientBackURL"));
|
|
form.fields().get("ClientBackURL"));
|
|
|
|
|
+ assertFalse(form.fields().containsKey("ClientRedirectURL"));
|
|
|
|
|
+ assertFalse(form.fields().containsKey("ExpireDate"));
|
|
|
|
|
+ assertFalse(form.fields().containsKey("StoreExpireDate"));
|
|
|
|
|
+ assertFalse(form.fields().containsKey("BarcodeATMExpireDate"));
|
|
|
assertEquals("Foodie order DDscript", form.fields().get("TradeDesc"));
|
|
assertEquals("Foodie order DDscript", form.fields().get("TradeDesc"));
|
|
|
assertFalse(form.fields().get("ItemName").contains("|"));
|
|
assertFalse(form.fields().get("ItemName").contains("|"));
|
|
|
assertTrue(form.fields().get("ItemName").length() <= 120);
|
|
assertTrue(form.fields().get("ItemName").length() <= 120);
|
|
|
- verify(signer).sign(org.mockito.ArgumentMatchers.argThat(fields -> fields.size() == 18
|
|
|
|
|
|
|
+ verify(signer).sign(org.mockito.ArgumentMatchers.argThat(fields -> fields.size() == 15
|
|
|
|
|
+ && "Credit".equals(fields.get("ChoosePayment"))
|
|
|
|
|
+ && "2".equals(fields.get("UnionPay"))
|
|
|
&& !fields.containsKey("CheckMacValue")), eq("KEY"), eq("IV"));
|
|
&& !fields.containsKey("CheckMacValue")), eq("KEY"), eq("IV"));
|
|
|
assertThrows(UnsupportedOperationException.class, () -> form.fields().put("extra", "value"));
|
|
assertThrows(UnsupportedOperationException.class, () -> form.fields().put("extra", "value"));
|
|
|
}
|
|
}
|
|
@@ -78,7 +82,6 @@ class OmgPaymentFormFactoryTest {
|
|
|
OmgPaymentProperties properties = new OmgPaymentProperties();
|
|
OmgPaymentProperties properties = new OmgPaymentProperties();
|
|
|
properties.setReturnUrl("https://foodieapi.waimai-paotui.com/pay/omg/notify");
|
|
properties.setReturnUrl("https://foodieapi.waimai-paotui.com/pay/omg/notify");
|
|
|
properties.setOrderResultUrl("https://foodieapi.waimai-paotui.com/pay/omg/result");
|
|
properties.setOrderResultUrl("https://foodieapi.waimai-paotui.com/pay/omg/result");
|
|
|
- properties.setClientRedirectUrl("https://foodieapi.waimai-paotui.com/pay/omg/payment-info-result");
|
|
|
|
|
properties.setClientBackUrl("https://foodieapi.waimai-paotui.com/pay/omg/back");
|
|
properties.setClientBackUrl("https://foodieapi.waimai-paotui.com/pay/omg/back");
|
|
|
properties.setAppReturnUrl("https://link.waimai-paotui.com/payment/omg");
|
|
properties.setAppReturnUrl("https://link.waimai-paotui.com/payment/omg");
|
|
|
return properties;
|
|
return properties;
|