@Test(groups = "slow")
  public void testGetPaymentInfo() throws Exception {
    final PaymentPluginApi api =
        getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);

    final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
    final PaymentTransactionInfoPlugin res =
        api.getPaymentInfo(
                UUID.randomUUID(),
                UUID.randomUUID(),
                ImmutableList.<PluginProperty>of(),
                callContext)
            .get(0);
    final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);

    Assert.assertTrue(res.getAmount().compareTo(BigDecimal.ZERO) == 0);
    Assert.assertTrue(res.getCreatedDate().compareTo(beforeCall) >= 0);
    Assert.assertTrue(res.getCreatedDate().compareTo(afterCall) <= 0);

    Assert.assertTrue(res.getEffectiveDate().compareTo(beforeCall) >= 0);
    Assert.assertTrue(res.getEffectiveDate().compareTo(afterCall) <= 0);

    assertEquals(res.getGatewayError(), "gateway_error");
    assertEquals(res.getGatewayErrorCode(), "gateway_error_code");

    assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
  }
예제 #2
0
 private List<PaymentTransactionInfoPlugin> getPaymentTransactionInfoPlugins(
     final PaymentPluginApi plugin,
     final PaymentModelDao paymentModelDao,
     final Iterable<PluginProperty> properties,
     final TenantContext context)
     throws PaymentApiException {
   try {
     return plugin.getPaymentInfo(
         paymentModelDao.getAccountId(), paymentModelDao.getId(), properties, context);
   } catch (final PaymentPluginApiException e) {
     throw new PaymentApiException(
         ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, paymentModelDao.getId(), e.toString());
   }
 }