|
@@ -98,8 +98,8 @@ public class ReceiptBillGatewayTest {
|
|
|
runtimeAccount.setApiKey(stored.getApiKey());
|
|
runtimeAccount.setApiKey(stored.getApiKey());
|
|
|
runtimeAccount.setRSAPrivateKey(key);
|
|
runtimeAccount.setRSAPrivateKey(key);
|
|
|
Adapay.addMerConfig(runtimeAccount, MERCHANT_KEY);
|
|
Adapay.addMerConfig(runtimeAccount, MERCHANT_KEY);
|
|
|
- ali.setPrivateKey(key); ali.setPublicKey(pub); ali.setAppId("ali-app"); ali.setEnable(false);
|
|
|
|
|
- wx.setMerchantId("10001"); wx.setEnable(false);
|
|
|
|
|
|
|
+ ali.setPrivateKey(key); ali.setPublicKey(pub); ali.setAppId("ali-app"); ali.setEnable(true);
|
|
|
|
|
+ wx.setMerchantId("10001"); wx.setEnable(true);
|
|
|
register("ALIPAY_101", ali, mock(BasePaymentService.class));
|
|
register("ALIPAY_101", ali, mock(BasePaymentService.class));
|
|
|
WxPaymentServicePlugin plugin = mock(WxPaymentServicePlugin.class);
|
|
WxPaymentServicePlugin plugin = mock(WxPaymentServicePlugin.class);
|
|
|
register("WXPAY_101", wx, plugin);
|
|
register("WXPAY_101", wx, plugin);
|
|
@@ -417,7 +417,15 @@ public class ReceiptBillGatewayTest {
|
|
|
@Test public void missingRegistrationIsDistinctFromMissingDirectAccount() throws Exception {
|
|
@Test public void missingRegistrationIsDistinctFromMissingDirectAccount() throws Exception {
|
|
|
when(payments.getPaymentService("ALIPAY_101")).thenThrow(new com.microsvc.toolkit.middleware.payment.common.exception.PaymentException("missing"));
|
|
when(payments.getPaymentService("ALIPAY_101")).thenThrow(new com.microsvc.toolkit.middleware.payment.common.exception.PaymentException("missing"));
|
|
|
assertTrue(fetch("101", "ALIPAY", DAY).getMessage().contains("有直连账户配置,但支付服务未注册该实例(ALIPAY_101)"));
|
|
assertTrue(fetch("101", "ALIPAY", DAY).getMessage().contains("有直连账户配置,但支付服务未注册该实例(ALIPAY_101)"));
|
|
|
- assertTrue(fetch("102", "WECHAT", DAY).getMessage().contains("未找到该机构的直连支付实例(WXPAY_102)"));
|
|
|
|
|
|
|
+ assertEquals(ReceiptBillDto.NOT_ENABLED, fetch("102", "WECHAT", DAY).getStatus());
|
|
|
|
|
+ assertEquals(0, requests);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test public void disabledDirectAccountsDoNotRequestStatementsOrBalances() throws Exception {
|
|
|
|
|
+ wx.setEnable(false);
|
|
|
|
|
+ ali.setEnable(false);
|
|
|
|
|
+ assertEquals(ReceiptBillDto.NOT_ENABLED, fetch("101", "WECHAT", DAY).getStatus());
|
|
|
|
|
+ assertEquals(ReceiptBillDto.NOT_ENABLED, fetch("101", "ALIPAY", DAY).getStatus());
|
|
|
assertEquals(0, requests);
|
|
assertEquals(0, requests);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -434,8 +442,7 @@ public class ReceiptBillGatewayTest {
|
|
|
assertEquals(0, requests);
|
|
assertEquals(0, requests);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Test public void missingConfigOrSecretsNotTreatedAsPendingEvenToday() throws Exception {
|
|
|
|
|
- assertEquals("ERROR", fetch("unconfigured", "WECHAT", DAY.plusDays(1)).getStatus());
|
|
|
|
|
|
|
+ @Test public void missingSecretsNotTreatedAsPendingEvenToday() throws Exception {
|
|
|
stored.setApiKey(null);
|
|
stored.setApiKey(null);
|
|
|
ReceiptBillDto bill = fetch("101", "HUIFU", DAY.plusDays(1));
|
|
ReceiptBillDto bill = fetch("101", "HUIFU", DAY.plusDays(1));
|
|
|
assertEquals("ERROR", bill.getStatus()); assertNull(bill.getAvailableBalance()); assertEquals(0, requests);
|
|
assertEquals("ERROR", bill.getStatus()); assertNull(bill.getAvailableBalance()); assertEquals(0, requests);
|
|
@@ -445,7 +452,7 @@ public class ReceiptBillGatewayTest {
|
|
|
supplements.put("mec.receipt.gateway.tenants.102.ALIPAY.appId", "ali-app");
|
|
supplements.put("mec.receipt.gateway.tenants.102.ALIPAY.appId", "ali-app");
|
|
|
for (String channel : ReceiptLedger.CHANNELS) {
|
|
for (String channel : ReceiptLedger.CHANNELS) {
|
|
|
ReceiptBillDto bill = fetch("102", channel, DAY);
|
|
ReceiptBillDto bill = fetch("102", channel, DAY);
|
|
|
- assertEquals("ERROR", bill.getStatus()); assertTrue(bill.getMessage().contains("未确认"));
|
|
|
|
|
|
|
+ assertEquals(ReceiptBillDto.NOT_ENABLED, bill.getStatus());
|
|
|
}
|
|
}
|
|
|
org.mockito.Mockito.verify(payments, never()).getPaymentService();
|
|
org.mockito.Mockito.verify(payments, never()).getPaymentService();
|
|
|
assertEquals(0, requests);
|
|
assertEquals(0, requests);
|
|
@@ -496,7 +503,7 @@ public class ReceiptBillGatewayTest {
|
|
|
assertTrue(fetch("101", "ALIPAY", DAY).getMessage().contains("商户 PID"));
|
|
assertTrue(fetch("101", "ALIPAY", DAY).getMessage().contains("商户 PID"));
|
|
|
supplements.put("app-pay.ali-pay-configs[ALIPAY_101].seller-id", PID);
|
|
supplements.put("app-pay.ali-pay-configs[ALIPAY_101].seller-id", PID);
|
|
|
assertEquals("READY", fetch("101", "ALIPAY", DAY).getStatus());
|
|
assertEquals("READY", fetch("101", "ALIPAY", DAY).getStatus());
|
|
|
- assertTrue(fetch("102", "ALIPAY", DAY).getMessage().contains("未确认"));
|
|
|
|
|
|
|
+ assertEquals(ReceiptBillDto.NOT_ENABLED, fetch("102", "ALIPAY", DAY).getStatus());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test public void wechatRejectsInvalidDatesAndWaitsBeforeCutoff() throws Exception {
|
|
@Test public void wechatRejectsInvalidDatesAndWaitsBeforeCutoff() throws Exception {
|