private void verifyPaymentViaGetPath(final Payment payment) throws PaymentApiException { // We can't use Assert.assertEquals because the updateDate may have been updated by the Janitor final Payment refreshedPayment = paymentApi.getPayment(payment.getId(), true, false, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(refreshedPayment.getAccountId(), payment.getAccountId()); Assert.assertEquals(refreshedPayment.getTransactions().size(), payment.getTransactions().size()); Assert.assertEquals(refreshedPayment.getExternalKey(), payment.getExternalKey()); Assert.assertEquals(refreshedPayment.getPaymentMethodId(), payment.getPaymentMethodId()); Assert.assertEquals(refreshedPayment.getAccountId(), payment.getAccountId()); Assert.assertEquals(refreshedPayment.getAuthAmount().compareTo(payment.getAuthAmount()), 0); Assert.assertEquals(refreshedPayment.getCapturedAmount().compareTo(payment.getCapturedAmount()), 0); Assert.assertEquals(refreshedPayment.getPurchasedAmount().compareTo(payment.getPurchasedAmount()), 0); Assert.assertEquals(refreshedPayment.getRefundedAmount().compareTo(payment.getRefundedAmount()), 0); Assert.assertEquals(refreshedPayment.getCurrency(), payment.getCurrency()); for (int i = 0; i < refreshedPayment.getTransactions().size(); i++) { final PaymentTransaction refreshedPaymentTransaction = refreshedPayment.getTransactions().get(i); final PaymentTransaction paymentTransaction = payment.getTransactions().get(i); Assert.assertEquals(refreshedPaymentTransaction.getAmount().compareTo(paymentTransaction.getAmount()), 0); Assert.assertEquals(refreshedPaymentTransaction.getProcessedAmount().compareTo(paymentTransaction.getProcessedAmount()), 0); Assert.assertEquals(refreshedPaymentTransaction.getCurrency(), paymentTransaction.getCurrency()); Assert.assertEquals(refreshedPaymentTransaction.getExternalKey(), paymentTransaction.getExternalKey()); Assert.assertEquals(refreshedPaymentTransaction.getTransactionStatus(), paymentTransaction.getTransactionStatus()); } }
public PaymentJson(final Payment dp, @Nullable final AccountAuditLogs accountAuditLogs) { this(dp.getAccountId(), dp.getId(), dp.getPaymentNumber().toString(), dp.getExternalKey(), dp.getAuthAmount(), dp.getCapturedAmount(), dp.getPurchasedAmount(), dp.getRefundedAmount(), dp.getCreditedAmount(), dp.getCurrency() != null ? dp.getCurrency() : null, dp.getPaymentMethodId(), getTransactions(dp.getTransactions(), dp.getExternalKey(), accountAuditLogs), getAttempts(dp.getPaymentAttempts(), dp.getExternalKey(), accountAuditLogs), toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForPayment(dp.getId()))); }
private void verifyPayment(final Payment payment, final String paymentExternalKey, final BigDecimal authAmount, final BigDecimal capturedAmount, final BigDecimal refundedAmount, final int transactionsSize) { Assert.assertEquals(payment.getAccountId(), account.getId()); // We cannot assume the number to be 1 here as the auto_increment implementation // depends on the database. On h2, it is implemented as a sequence, and the payment number // would be 33, 34, 35, etc. depending on the test // See also http://h2database.com/html/grammar.html#create_sequence Assert.assertTrue(payment.getPaymentNumber() > 0); Assert.assertEquals(payment.getExternalKey(), paymentExternalKey); Assert.assertEquals(payment.getAuthAmount().compareTo(authAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(capturedAmount), 0); Assert.assertEquals(payment.getRefundedAmount().compareTo(refundedAmount), 0); Assert.assertEquals(payment.getCurrency(), CURRENCY); Assert.assertEquals(payment.getTransactions().size(), transactionsSize); }
protected Payment createChargeBackAndCheckForCompletion(final Account account, final Payment payment, final NextEvent... events) { return createChargeBackAndCheckForCompletion(account, payment, payment.getPurchasedAmount(), payment.getCurrency(), events); }
@Test(groups = "slow") public void testCreateAuthWithControlCaptureNoControl() throws PaymentApiException { final BigDecimal requestedAmount = BigDecimal.TEN; Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, account.getPaymentMethodId(), null, requestedAmount, Currency.USD, null,UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); verifyOnSuccess(payment.getId(), payment.getExternalKey(), payment.getTransactions().get(0).getId(), payment.getTransactions().get(0).getExternalKey(), requestedAmount, Currency.USD); payment = paymentApi.createCapture(account, payment.getId(), payment.getAuthAmount(), payment.getCurrency(), null,UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); }
@Test(groups = "fast") public void testAmountsPurchaseChargeback() throws Exception { final UUID paymentId = UUID.randomUUID(); final String chargebackExternalKey = UUID.randomUUID().toString(); final List<PaymentTransaction> transactions = ImmutableList.<PaymentTransaction>of(buildPaymentTransaction(paymentId, UUID.randomUUID().toString(), TransactionType.PURCHASE, TransactionStatus.SUCCESS, BigDecimal.TEN), buildPaymentTransaction(paymentId, chargebackExternalKey, TransactionType.CHARGEBACK, TransactionStatus.SUCCESS, BigDecimal.TEN)); final Payment payment = buildPayment(paymentId, transactions); Assert.assertEquals(payment.getAuthAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getRefundedAmount().compareTo(BigDecimal.ZERO), 0); }
public static Payment buildPayment(final UUID accountId, final UUID paymentMethodId, final UUID paymentId, final Currency currency, final String paymentExternalKey, @Nullable final OSGIKillbill killbillApi) throws PaymentApiException { final Payment payment = Mockito.mock(Payment.class); Mockito.when(payment.getId()).thenReturn(paymentId); Mockito.when(payment.getExternalKey()).thenReturn(paymentExternalKey); Mockito.when(payment.getAccountId()).thenReturn(accountId); Mockito.when(payment.getPaymentMethodId()).thenReturn(paymentMethodId); Mockito.when(payment.getPaymentNumber()).thenReturn(1); Mockito.when(payment.getCapturedAmount()).thenReturn(new BigDecimal("199999")); Mockito.when(payment.getRefundedAmount()).thenReturn(new BigDecimal("199998")); Mockito.when(payment.getCurrency()).thenReturn(currency); Mockito.when(payment.getTransactions()).thenReturn(new LinkedList<PaymentTransaction>()); Mockito.when(payment.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 56, DateTimeZone.UTC)); if (killbillApi != null) { Mockito.when(killbillApi.getPaymentApi().getPayment(Mockito.eq(payment.getId()), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(payment); final List<Payment> payments = MoreObjects.firstNonNull(killbillApi.getPaymentApi().getAccountPayments(accountId, false, false, ImmutableList.<PluginProperty>of(), Mockito.mock(TenantContext.class)), new LinkedList<Payment>()); payments.add(payment); Mockito.when(killbillApi.getPaymentApi().getAccountPayments(Mockito.eq(accountId), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(payments); } return payment; }
@Test(groups = "slow") public void testFailedInitialTransactionToSameTransactionWithSameKey() throws Exception { final BigDecimal requestedAmount = BigDecimal.TEN; for (final TransactionType transactionType : ImmutableList.<TransactionType>of(TransactionType.AUTHORIZE, TransactionType.PURCHASE, TransactionType.CREDIT)) { final String paymentExternalKey = UUID.randomUUID().toString(); final String keyA = UUID.randomUUID().toString(); final Payment errorPayment = createPayment(transactionType, null, paymentExternalKey, keyA, requestedAmount, PaymentPluginStatus.ERROR); assertNotNull(errorPayment); Assert.assertEquals(errorPayment.getTransactions().size(), 1); Assert.assertEquals(errorPayment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.PAYMENT_FAILURE); // Attempt to create another {AUTH, PURCHASE, CREDIT} with same key => That should work because we are completing the payment final Payment successfulPayment = createPayment(transactionType, errorPayment.getId(), paymentExternalKey, keyA, requestedAmount, PaymentPluginStatus.PROCESSED); assertNotNull(successfulPayment); Assert.assertEquals(successfulPayment.getId(), errorPayment.getId()); Assert.assertEquals(successfulPayment.getTransactions().size(), 2); } }
fail("Expected to fail because requested amount > invoice amount"); assertNotNull(paymentInfo.getId()); assertTrue(paymentInfo.getPurchasedAmount().compareTo(MoreObjects.firstNonNull(expectedAmount, invoiceAmount)) == 0); assertNotNull(paymentInfo.getPaymentNumber()); assertEquals(paymentInfo.getExternalKey(), invoice.getId().toString()); assertEquals(paymentInfo.getCurrency(), Currency.USD); assertTrue(paymentInfo.getTransactions().get(0).getAmount().compareTo(MoreObjects.firstNonNull(expectedAmount, invoiceAmount)) == 0); assertEquals(paymentInfo.getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(paymentInfo.getTransactions().get(0).getPaymentId(), paymentInfo.getId()); assertEquals(paymentInfo.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertEquals(paymentInfo.getTransactions().get(0).getTransactionStatus(), TransactionStatus.SUCCESS);
@Test(groups = "slow") public void testCreateAuthWithControl() throws PaymentApiException { final PaymentMethodPlugin paymentMethodInfo = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, null); final UUID newPaymentMethodId = paymentApi.addPaymentMethod(account, null, MockPaymentProviderPlugin.PLUGIN_NAME, false, paymentMethodInfo, ImmutableList.<PluginProperty>of(), callContext); testPaymentControlPluginApi.setNewPaymentMethodId(newPaymentMethodId); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, account.getPaymentMethodId(), null, BigDecimal.TEN, Currency.USD, null,null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); Assert.assertEquals(payment.getPaymentMethodId(), newPaymentMethodId); verifyOnSuccess(payment.getId(), payment.getExternalKey(), payment.getTransactions().get(0).getId(), payment.getTransactions().get(0).getExternalKey(), BigDecimal.TEN, Currency.USD); }
@Test(groups = "slow") public void testAuthCaptureWithPaymentControl() throws Exception { final AccountData accountData = getAccountData(1); final Account account = createAccountWithNonOsgiPaymentMethod(accountData); busHandler.pushExpectedEvents(NextEvent.PAYMENT); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, account.getPaymentMethodId(), null, BigDecimal.ONE, account.getCurrency(), null, null, null, properties, paymentOptions, callContext); assertListenerStatus(); Payment paymentWithAttempts = paymentApi.getPayment(payment.getId(), false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().size(), 1); Assert.assertEquals(paymentWithAttempts.getExternalKey(), paymentWithAttempts.getPaymentAttempts().get(0).getPaymentExternalKey()); Assert.assertEquals(paymentWithAttempts.getTransactions().get(0).getExternalKey(), paymentWithAttempts.getPaymentAttempts().get(0).getTransactionExternalKey()); // Verify fix for https://github.com/killbill/killbill/issues/349 when no external key is set Assert.assertEquals(paymentWithAttempts.getId().toString(), paymentWithAttempts.getPaymentAttempts().get(0).getPaymentExternalKey()); Assert.assertEquals(paymentWithAttempts.getTransactions().get(0).getId().toString(), paymentWithAttempts.getPaymentAttempts().get(0).getTransactionExternalKey()); busHandler.pushExpectedEvents(NextEvent.PAYMENT); paymentApi.createCaptureWithPaymentControl(account, payment.getId(), BigDecimal.ONE, account.getCurrency(), null, null, properties, paymentOptions, callContext); assertListenerStatus(); paymentWithAttempts = paymentApi.getPayment(payment.getId(), false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().size(), 2); Assert.assertEquals(paymentWithAttempts.getTransactions().get(1).getExternalKey(), paymentWithAttempts.getPaymentAttempts().get(1).getTransactionExternalKey()); Assert.assertEquals(paymentWithAttempts.getTransactions().get(1).getId().toString(), paymentWithAttempts.getPaymentAttempts().get(1).getTransactionExternalKey()); Assert.assertEquals(testPaymentControlWithControl.getCalls().size(), 2); Assert.assertEquals(testPaymentControlWithControl.getCalls().get(TransactionType.AUTHORIZE.toString()), new Integer(1)); Assert.assertEquals(testPaymentControlWithControl.getCalls().get(TransactionType.CAPTURE.toString()), new Integer(1)); }
@Override public Payment answer(final InvocationOnMock invocation) throws Throwable { final UUID accountId = ((Account) invocation.getArguments()[0]).getId(); final UUID paymentMethodId = (UUID) invocation.getArguments()[1]; final UUID paymentId = MoreObjects.firstNonNull((UUID) invocation.getArguments()[2], UUID.randomUUID()); final BigDecimal amount = (BigDecimal) invocation.getArguments()[3]; final Currency currency = (Currency) invocation.getArguments()[4]; final String paymentExternalKey = MoreObjects.firstNonNull((String) invocation.getArguments()[6], UUID.randomUUID().toString()); final String paymentTransactionExternalKey = MoreObjects.firstNonNull((String) invocation.getArguments()[7], paymentExternalKey); final Payment payment = buildPayment(accountId, paymentMethodId, paymentId, currency, paymentExternalKey, killbillApi); final PaymentTransaction paymentTransaction = buildPaymentTransaction(payment, paymentTransactionExternalKey, TransactionType.PURCHASE, TransactionStatus.UNKNOWN, amount, currency); final PaymentTransactionInfoPlugin transactionInfoPlugin = paymentPluginApi.purchasePayment(payment.getAccountId(), payment.getId(), paymentTransaction.getId(), payment.getPaymentMethodId(), paymentTransaction.getAmount(), paymentTransaction.getCurrency(), (Iterable<PluginProperty>) invocation.getArguments()[invocation.getArguments().length - 2], (CallContext) invocation.getArguments()[invocation.getArguments().length - 1]); updatePaymentTransaction(paymentTransaction, transactionInfoPlugin); return payment; } });
assertEquals(payments.get(0).getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments.get(0).getTransactions().size(), 1); assertEquals(payments.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getProcessedAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.PENDING); assertEquals(payments.get(0).getPaymentAttempts().size(), 1); assertEquals(payments.get(0).getPaymentAttempts().get(0).getPluginName(), InvoicePaymentControlPluginApi.PLUGIN_NAME); assertEquals(payments.get(0).getPaymentAttempts().get(0).getStateName(), "SUCCESS"); paymentApi.notifyPendingTransactionOfStateChangedWithPaymentControl(account, payments.get(0).getTransactions().get(0).getId(), false, paymentOptions, callContext); assertListenerStatus(); assertEquals(payments2.get(0).getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments2.get(0).getTransactions().size(), 1); assertEquals(payments2.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.PAYMENT_FAILURE); assertEquals(payments2.get(0).getPaymentAttempts().size(), 1); assertEquals(payments2.get(0).getPaymentAttempts().get(0).getPluginName(), InvoicePaymentControlPluginApi.PLUGIN_NAME); assertEquals(payments2.get(0).getPaymentAttempts().get(0).getStateName(), "ABORTED");
@Test(groups = "slow") public void testVerifyJanitorFromPendingDuringCompletionFlow() throws PaymentApiException { final BigDecimal authAmount = BigDecimal.TEN; final String transactionExternalKey = UUID.randomUUID().toString(); final Payment initialPayment = createPayment(TransactionType.AUTHORIZE, null, UUID.randomUUID().toString(), transactionExternalKey, authAmount, PaymentPluginStatus.PENDING); Assert.assertEquals(initialPayment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.PENDING); mockPaymentProviderPlugin.overridePaymentPluginStatus(initialPayment.getId(), initialPayment.getTransactions().get(0).getId(), PaymentPluginStatus.PROCESSED); try { final Payment completedPayment = createPayment(TransactionType.AUTHORIZE, initialPayment.getId(), initialPayment.getExternalKey(), transactionExternalKey, authAmount, PaymentPluginStatus.PROCESSED); Assert.fail(); } catch (final PaymentApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_ACTIVE_TRANSACTION_KEY_EXISTS.getCode()); } }
private List<AuditLog> getAuditLogForPayment(final Payment payment, final TenantContext context) { return auditUserApi.getAccountAuditLogs(payment.getAccountId(), AuditLevel.FULL, context).getAuditLogsForPayment(payment.getId()); }
protected Map<UUID, List<InvoicePayment>> getAccountInvoicePayments(final Iterable<Payment> payments, final TenantContext context) throws OSGIServiceNotAvailable { final InvoicePaymentApi invoicePaymentApi = getInvoicePaymentUserApi(); final Map<UUID, List<InvoicePayment>> allInvoicePaymentsByPaymentId = new HashMap<UUID, List<InvoicePayment>>(); for (final Payment payment : payments) { // Retrieve all invoice payment types (including refunds and chargebacks) for that payment allInvoicePaymentsByPaymentId.put(payment.getId(), invoicePaymentApi.getInvoicePayments(payment.getId(), context)); } return allInvoicePaymentsByPaymentId; }
@Test(groups = "slow") public void testFailedRefundWithInvoiceAdjustment() throws Exception { try { invoicePaymentApi.createRefundForInvoicePayment(true, null, account, payment.getId(), payment.getPurchasedAmount(), payment.getCurrency(), null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); fail("Refund with invoice adjustment should now throw an Exception"); } catch (final PaymentApiException e) { Assert.assertEquals(e.getCause(), null); // Unfortunately we lose the original error code : INVOICE_ITEMS_ADJUSTMENT_MISSING Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_PLUGIN_EXCEPTION.getCode()); } }
@Test(groups = "slow") public void testAuthSuccessWithPaymentControlNullPaymentMethodId() throws Exception { final AccountData accountData = getAccountData(1); final Account account = accountUserApi.createAccount(accountData, callContext); // Add non-default payment method final PaymentMethodPlugin info = createPaymentMethodPlugin(); final UUID paymentMethodId = paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, false, info, PLUGIN_PROPERTIES, callContext); testPaymentControlWithControl.setAdjustedPaymentMethodId(paymentMethodId); busHandler.pushExpectedEvents(NextEvent.PAYMENT); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, null, null, BigDecimal.ONE, account.getCurrency(), null, null, null, properties, paymentOptions, callContext); assertListenerStatus(); final Payment paymentWithAttempts = paymentApi.getPayment(payment.getId(), false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentWithAttempts.getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().size(), 1); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getStateName(), "SUCCESS"); }
assertEquals(payments.get(0).getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments.get(0).getTransactions().size(), 1); assertEquals(payments.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getProcessedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.UNKNOWN); assertEquals(payments.get(0).getPaymentAttempts().size(), 1); assertEquals(payments.get(0).getPaymentAttempts().get(0).getPluginName(), InvoicePaymentControlPluginApi.PLUGIN_NAME); assertEquals(payments.get(0).getPaymentAttempts().get(0).getStateName(), "ABORTED"); paymentPlugin.overridePaymentPluginStatus(payments.get(0).getId(), payments.get(0).getTransactions().get(0).getId(), PaymentPluginStatus.PROCESSED); paymentApi.getPayment(payments.get(0).getId(), true, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); assertEquals(payments2.get(0).getPurchasedAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().size(), 1); assertEquals(payments2.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.SUCCESS); assertEquals(payments2.get(0).getPaymentAttempts().size(), 1); assertEquals(payments2.get(0).getPaymentAttempts().get(0).getPluginName(), InvoicePaymentControlPluginApi.PLUGIN_NAME); assertEquals(payments2.get(0).getPaymentAttempts().get(0).getStateName(), "SUCCESS");
assertEquals(payments.get(0).getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments.get(0).getTransactions().size(), 1); assertEquals(payments.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getProcessedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payments.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.UNKNOWN); assertEquals(payments.get(0).getPaymentAttempts().size(), 1); assertEquals(payments.get(0).getPaymentAttempts().get(0).getPluginName(), InvoicePaymentControlPluginApi.PLUGIN_NAME); assertEquals(payments.get(0).getPaymentAttempts().get(0).getStateName(), "ABORTED"); invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice1.getId(), payments.get(0).getPaymentMethodId(), null, invoice1.getBalance(), final PaymentTransaction existingPaymentTransaction = payments.get(0).getTransactions().get(0); final PaymentTransaction updatedPaymentTransaction = Mockito.mock(PaymentTransaction.class); Mockito.when(updatedPaymentTransaction.getId()).thenReturn(existingPaymentTransaction.getId()); assertEquals(payments2.get(0).getPurchasedAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().size(), 1); assertEquals(payments2.get(0).getTransactions().get(0).getAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedAmount().compareTo(new BigDecimal("249.95")), 0); assertEquals(payments2.get(0).getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payments2.get(0).getTransactions().get(0).getTransactionStatus(), TransactionStatus.SUCCESS); assertEquals(payments2.get(0).getPaymentAttempts().size(), 1);