@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 testNotifyPendingTransactionOfStateChanged() throws PaymentApiException { final BigDecimal authAmount = BigDecimal.TEN; final String paymentExternalKey = "rouge"; final String transactionExternalKey = "vert"; final Payment initialPayment = createPayment(TransactionType.AUTHORIZE, null, paymentExternalKey, transactionExternalKey, authAmount, PaymentPluginStatus.PENDING); final Payment payment = paymentApi.notifyPendingTransactionOfStateChanged(account, initialPayment.getTransactions().get(0).getId(), true, callContext); assertEquals(payment.getExternalKey(), paymentExternalKey); assertEquals(payment.getPaymentMethodId(), account.getPaymentMethodId()); assertEquals(payment.getAccountId(), account.getId()); assertEquals(payment.getAuthAmount().compareTo(authAmount), 0); assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getPurchasedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getRefundedAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(payment.getCurrency(), Currency.USD); 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(authAmount), 0); assertEquals(payment.getTransactions().get(0).getCurrency(), Currency.USD); assertEquals(payment.getTransactions().get(0).getProcessedAmount().compareTo(authAmount), 0); assertEquals(payment.getTransactions().get(0).getProcessedCurrency(), Currency.USD); assertEquals(payment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.SUCCESS); assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.AUTHORIZE); assertNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNull(payment.getTransactions().get(0).getGatewayErrorCode()); }
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode());
assertEquals(payment4.getTransactions().get(3).getTransactionType(), TransactionType.REFUND); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorMsg()); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.AUTHORIZE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); assertEquals(payment2.getTransactions().get(1).getTransactionType(), TransactionType.VOID); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorMsg()); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.AUTHORIZE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); assertEquals(payment2.getTransactions().get(1).getTransactionType(), TransactionType.CAPTURE); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorMsg()); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertEquals(payment.getTransactions().get(0).getGatewayErrorMsg(), ""); assertEquals(payment.getTransactions().get(0).getGatewayErrorCode(), "");
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.AUTHORIZE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); assertEquals(payment2.getTransactions().get(1).getTransactionType(), TransactionType.CAPTURE); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorMsg()); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorCode()); assertEquals(payment3.getTransactions().get(2).getTransactionType(), TransactionType.VOID); assertNotNull(payment3.getTransactions().get(2).getGatewayErrorMsg()); assertNotNull(payment3.getTransactions().get(2).getGatewayErrorCode()); assertEquals(payment4.getTransactions().get(3).getTransactionType(), TransactionType.VOID); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorMsg()); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.AUTHORIZE); assertNotNull(payment.getTransactions().get(0).getGatewayErrorMsg()); assertNotNull(payment.getTransactions().get(0).getGatewayErrorCode()); assertEquals(payment2.getTransactions().get(1).getTransactionType(), TransactionType.CAPTURE); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorMsg()); assertNotNull(payment2.getTransactions().get(1).getGatewayErrorCode()); assertEquals(payment3.getTransactions().get(2).getTransactionType(), TransactionType.VOID); assertNotNull(payment3.getTransactions().get(2).getGatewayErrorMsg()); assertNotNull(payment3.getTransactions().get(2).getGatewayErrorCode()); assertEquals(payment4.getTransactions().get(3).getTransactionType(), TransactionType.CAPTURE); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorMsg()); assertNotNull(payment4.getTransactions().get(3).getGatewayErrorCode());
assertEquals(payment.getTransactions().get(0).getTransactionType(), TransactionType.PURCHASE); assertEquals(payment.getTransactions().get(0).getGatewayErrorMsg(), ""); assertEquals(payment.getTransactions().get(0).getGatewayErrorCode(), ""); assertEquals(payment2.getTransactions().get(1).getTransactionType(), TransactionType.CHARGEBACK); assertNull(payment2.getTransactions().get(1).getGatewayErrorMsg()); assertNull(payment2.getTransactions().get(1).getGatewayErrorCode()); assertEquals(payment3.getTransactions().get(2).getTransactionType(), TransactionType.CHARGEBACK); assertNull(payment3.getTransactions().get(2).getGatewayErrorMsg()); assertNull(payment3.getTransactions().get(2).getGatewayErrorCode()); assertEquals(payment4.getTransactions().get(3).getTransactionType(), TransactionType.REFUND); assertEquals(payment4.getTransactions().get(3).getGatewayErrorMsg(), ""); assertEquals(payment4.getTransactions().get(3).getGatewayErrorCode(), ""); assertEquals(payment5.getTransactions().get(4).getTransactionType(), TransactionType.CHARGEBACK); assertNull(payment5.getTransactions().get(4).getGatewayErrorMsg()); assertNull(payment5.getTransactions().get(4).getGatewayErrorCode()); assertEquals(payment6.getTransactions().get(5).getTransactionType(), TransactionType.CHARGEBACK); assertNull(payment6.getTransactions().get(5).getGatewayErrorMsg()); assertNull(payment6.getTransactions().get(5).getGatewayErrorCode());
public PaymentTransactionJson(final PaymentTransaction transaction, final String paymentExternalKey, @Nullable final List<AuditLog> transactionLogs) { this(transaction.getId(), transaction.getExternalKey(), transaction.getPaymentId(), paymentExternalKey, transaction.getTransactionType(), transaction.getAmount(), transaction.getCurrency() != null ? transaction.getCurrency() : null, transaction.getEffectiveDate(), transaction.getProcessedAmount(), transaction.getProcessedCurrency() != null ? transaction.getProcessedCurrency() : null, transaction.getTransactionStatus() != null ? transaction.getTransactionStatus().toString() : null, transaction.getGatewayErrorCode(), transaction.getGatewayErrorMsg(), transaction.getPaymentInfoPlugin() == null ? null : transaction.getPaymentInfoPlugin().getFirstPaymentReferenceId(), transaction.getPaymentInfoPlugin() == null ? null : transaction.getPaymentInfoPlugin().getSecondPaymentReferenceId(), transaction.getPaymentInfoPlugin() == null ? null : toPluginPropertyJson(transaction.getPaymentInfoPlugin().getProperties()), toAuditLogJson(transactionLogs)); }