@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 = "slow") public void testCreateAuthNoControlCaptureWithControl() throws PaymentApiException { final BigDecimal requestedAmount = BigDecimal.TEN; Payment payment = paymentApi.createAuthorization(account, account.getPaymentMethodId(), null, requestedAmount, Currency.USD, null,UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); payment = paymentApi.createCaptureWithPaymentControl(account, payment.getId(), payment.getAuthAmount(), payment.getCurrency(), null,UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); verifyOnSuccessForFollowOnTransaction(payment.getId(), payment.getExternalKey(), payment.getTransactions().get(1).getId(), payment.getTransactions().get(1).getExternalKey(), requestedAmount, Currency.USD); }
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.PENDING); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.SUCCESS); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.PENDING); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.SUCCESS); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
@Test(groups = "slow") public void testCreateAuthPendingNoControlCompleteWithControl() throws PaymentApiException { final String paymentTransactionExternalKey = UUID.randomUUID().toString(); final BigDecimal requestedAmount = BigDecimal.TEN; final Iterable<PluginProperty> pendingPluginProperties = ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, PaymentPluginStatus.PENDING, false)); Payment payment = paymentApi.createAuthorization(account, account.getPaymentMethodId(), null, requestedAmount, Currency.USD, null,UUID.randomUUID().toString(), paymentTransactionExternalKey, pendingPluginProperties, callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); payment = paymentApi.createAuthorizationWithPaymentControl(account, payment.getPaymentMethodId(), payment.getId(), requestedAmount, payment.getCurrency(), null,payment.getExternalKey(), payment.getTransactions().get(0).getExternalKey(), 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()); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey); verifyPriorAndOnSuccess(payment.getId(), payment.getExternalKey(), payment.getTransactions().get(0).getId(), payment.getTransactions().get(0).getExternalKey(), requestedAmount, Currency.USD); }
@Test(groups = "slow") public void testCreateAuthPendingWithControlCompleteNoControl() throws PaymentApiException { final String paymentTransactionExternalKey = UUID.randomUUID().toString(); final BigDecimal requestedAmount = BigDecimal.TEN; final Iterable<PluginProperty> pendingPluginProperties = ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, PaymentPluginStatus.PENDING, false)); Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, account.getPaymentMethodId(), null, requestedAmount, Currency.USD, null,UUID.randomUUID().toString(), paymentTransactionExternalKey, pendingPluginProperties, PAYMENT_OPTIONS, callContext); Assert.assertEquals(payment.getAuthAmount().compareTo(BigDecimal.ZERO), 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.createAuthorization(account, account.getPaymentMethodId(), payment.getId(), requestedAmount, payment.getCurrency(), null,payment.getExternalKey(), payment.getTransactions().get(0).getExternalKey(), ImmutableList.<PluginProperty>of(), 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()); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey); }
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.PENDING); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(requestedAmount), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.SUCCESS); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 2); Assert.assertNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(1)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(1).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(1).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey);
Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getCapturedAmount().compareTo(BigDecimal.ZERO), 0); Assert.assertEquals(payment.getTransactions().size(), 1); Assert.assertNotNull(((DefaultPaymentTransaction) payment.getTransactions().get(0)).getAttemptId()); Assert.assertEquals(payment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.UNKNOWN); Assert.assertEquals(payment.getTransactions().get(0).getExternalKey(), paymentTransactionExternalKey);