@Test(groups = "slow", description = "Verify we can make a refund on payment whose original payment method was deleted. See 694") public void testRefundAfterDeletedPaymentMethod() throws PaymentApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.EUR, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), callContext); paymentApi.deletePaymentMethod(account, account.getPaymentMethodId(), false, true, ImmutableList.<PluginProperty>of(), callContext); final Payment newPayment = paymentApi.createRefund(account, payment.getId(),requestedAmount, Currency.EUR, null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(newPayment.getTransactions().size(), 2); }
case PURCHASE: if (paymentOptions == null) { createdPayment = osgiKillbillAPI.getPaymentApi().createPurchase(account, kbPaymentMethodId, kbPaymentId,
@Test(groups = "slow") public void testCreatePurchasePaymentPluginException() { mockPaymentProviderPlugin.makeNextPaymentFailWithException(); final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "pay external key"; final String transactionExternalKey = "txn external key"; try { paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); fail(); } catch (PaymentApiException e) { assertTrue(e.getCause() instanceof PaymentPluginApiException); } }
@Test(groups = "slow") public void testCreatePurchaseWithTimeout() throws Exception { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "ohhhh"; final String transactionExternalKey = "naaahhh"; mockPaymentProviderPlugin.makePluginWaitSomeMilliseconds((int) (paymentConfig.getPaymentPluginTimeout().getMillis() + 100)); try { paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); fail(); } catch (PaymentApiException e) { assertEquals(e.getCode(), ErrorCode.PAYMENT_PLUGIN_TIMEOUT.getCode()); } }
Mockito.when(killbillApi.getPaymentApi().createPurchase(Mockito.<Account>any(), Mockito.<UUID>any(), Mockito.<UUID>any(),
@Test(groups = "slow") public void testCreateSuccessPurchase() throws PaymentApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "bwwrr"; final String transactionExternalKey = "krapaut"; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); assertEquals(payment.getExternalKey(), paymentExternalKey); assertEquals(payment.getPaymentMethodId(), account.getPaymentMethodId()); assertEquals(payment.getAccountId(), account.getId()); assertEquals(payment.getAuthAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getPurchasedAmount().compareTo(requestedAmount), 0); assertEquals(payment.getRefundedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getCurrency(), Currency.AED); assertEquals(payment.getTransactions().size(), 1); assertEquals(payment.getTransactions().get(0).getExternalKey(), transactionExternalKey); assertEquals(payment.getTransactions().get(0).getPaymentId(), payment.getId()); assertEquals(payment.getTransactions().get(0).getAmount().compareTo(requestedAmount), 0); assertEquals(payment.getTransactions().get(0).getCurrency(), Currency.AED); assertEquals(payment.getTransactions().get(0).getProcessedAmount().compareTo(requestedAmount), 0); assertEquals(payment.getTransactions().get(0).getProcessedCurrency(), Currency.AED); assertEquals(payment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.SUCCESS); assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); }
@Test(groups = "slow") public void testGetPaymentMethodsWithAndWithoutPluginInfo() throws PaymentApiException, PaymentPluginApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "externalKey"; final String transactionExternalKey = "transactionKey"; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); final Pagination<PaymentMethod> paymentMethods = paymentApi.getPaymentMethods(0L, 10L, false, null, callContext); final Pagination<PaymentMethod> paymentMethodsPlugin = paymentApi.getPaymentMethods(0L, 10L, true, null, callContext); Assert.assertTrue(paymentMethods.getTotalNbRecords() == 1); Assert.assertTrue(paymentMethodsPlugin.getTotalNbRecords() == 1); PaymentMethod paymentMethod = paymentMethods.iterator().next(); PaymentMethod paymentMethodPlugin = paymentMethodsPlugin.iterator().next(); Assert.assertEquals(paymentMethod.getAccountId(), paymentMethodPlugin.getAccountId()); Assert.assertEquals(paymentMethod.getId(), paymentMethodPlugin.getId()); Assert.assertEquals(paymentMethod.getExternalKey(), paymentMethodPlugin.getExternalKey()); Assert.assertEquals(paymentMethod.getPluginName(), paymentMethodPlugin.getPluginName()); Assert.assertNull(paymentMethod.getPluginDetail()); Assert.assertNotNull(paymentMethodPlugin.getPluginDetail()); Assert.assertTrue(paymentMethodPlugin.getPluginDetail().getProperties().isEmpty()); }
final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); final Payment payment2 = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext);
final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); final Payment payment2 = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext);
@Test(groups = "slow") public void testGetPaymentInfoWithAndWithoutPluginInfo() throws PaymentApiException, PaymentPluginApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "externalKey"; final String transactionExternalKey = "transactionKey"; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); final Payment paymentPluginInfoFalse = paymentApi.getPayment(payment.getId(), false, false, ImmutableList.<PluginProperty>of(), callContext); final Payment paymentPluginInfoTrue = paymentApi.getPayment(payment.getId(), true, false, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentPluginInfoFalse.getAccountId(), paymentPluginInfoTrue.getAccountId()); Assert.assertEquals(paymentPluginInfoFalse.getTransactions().size(), paymentPluginInfoTrue.getTransactions().size()); Assert.assertEquals(paymentPluginInfoFalse.getExternalKey(), paymentPluginInfoTrue.getExternalKey()); Assert.assertEquals(paymentPluginInfoFalse.getPaymentMethodId(), paymentPluginInfoTrue.getPaymentMethodId()); Assert.assertEquals(paymentPluginInfoFalse.getAccountId(), paymentPluginInfoTrue.getAccountId()); Assert.assertEquals(paymentPluginInfoFalse.getAuthAmount().compareTo(paymentPluginInfoTrue.getAuthAmount()), 0); Assert.assertEquals(paymentPluginInfoFalse.getCapturedAmount().compareTo(paymentPluginInfoTrue.getCapturedAmount()), 0); Assert.assertEquals(paymentPluginInfoFalse.getPurchasedAmount().compareTo(paymentPluginInfoTrue.getPurchasedAmount()), 0); Assert.assertEquals(paymentPluginInfoFalse.getRefundedAmount().compareTo(paymentPluginInfoTrue.getRefundedAmount()), 0); Assert.assertEquals(paymentPluginInfoFalse.getCurrency(), paymentPluginInfoTrue.getCurrency()); for (int i = 0; i < paymentPluginInfoFalse.getTransactions().size(); i++) { final PaymentTransaction noPluginInfoPaymentTransaction = paymentPluginInfoFalse.getTransactions().get(i); final PaymentTransaction paymentTransaction = paymentPluginInfoTrue.getTransactions().get(i); Assert.assertEquals(noPluginInfoPaymentTransaction.getAmount().compareTo(paymentTransaction.getAmount()), 0); Assert.assertEquals(noPluginInfoPaymentTransaction.getProcessedAmount().compareTo(paymentTransaction.getProcessedAmount()), 0); Assert.assertEquals(noPluginInfoPaymentTransaction.getCurrency(), paymentTransaction.getCurrency()); Assert.assertEquals(noPluginInfoPaymentTransaction.getExternalKey(), paymentTransaction.getExternalKey()); Assert.assertEquals(noPluginInfoPaymentTransaction.getTransactionStatus(), paymentTransaction.getTransactionStatus()); Assert.assertEquals(noPluginInfoPaymentTransaction.getPaymentInfoPlugin(), paymentTransaction.getPaymentInfoPlugin()); } }
Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); final Payment payment1 = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); final Payment payment2 = paymentApi.createPurchase(account, secondPmId, null,
@Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/675") public void testHandleLockExceptions() throws PaymentApiException { final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null,
final ImmutableList<PluginProperty> properties = ImmutableList.<PluginProperty>of(); final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null,
@Test(groups = "slow", description = "https://github.com/killbill/killbill-adyen-plugin/pull/60") public void testFixPaymentTransactionStateRefundSuccessToRefundFailed() throws PaymentApiException { final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null,
@Test(groups = "slow", description = "https://github.com/killbill/killbill-adyen-plugin/pull/60") public void testFixPaymentTransactionStateRefundFailedToRefundSuccess() throws PaymentApiException { final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null,
callContext); case PURCHASE: return paymentApi.createPurchase(account, account.getPaymentMethodId(), paymentId,
final ImmutableList<PluginProperty> properties = ImmutableList.<PluginProperty>of(); final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null,