use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPayment method testComboAuthorizationControlPluginException.
@Test(groups = "slow")
public void testComboAuthorizationControlPluginException() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
mockPaymentControlProviderPlugin.throwsException(new IllegalStateException());
try {
paymentApi.createComboPayment(comboPaymentTransaction, Arrays.asList(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
fail();
} catch (KillBillClientException e) {
assertEquals(e.getResponse().getStatusCode(), 500);
}
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPayment method testDeletePaymentMethodWithAutoPayOff.
@Test(groups = "slow")
public void testDeletePaymentMethodWithAutoPayOff() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
final UUID paymentMethodId = account.getPaymentMethodId();
RequestOptions inputOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).build();
paymentMethodApi.deletePaymentMethod(paymentMethodId, true, false, NULL_PLUGIN_PROPERTIES, inputOptions);
Tags accountTags = accountApi.getAccountTags(account.getAccountId(), inputOptions);
Assert.assertNotNull(accountTags);
Assert.assertEquals(accountTags.get(0).getTagDefinitionName(), "AUTO_PAY_OFF");
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPayment method testWithTimeoutPayment.
@Test(groups = "slow")
public void testWithTimeoutPayment() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
mockPaymentProviderPlugin.makePluginWaitSomeMilliseconds(10000);
final PaymentTransaction authTransaction = new PaymentTransaction();
authTransaction.setAmount(BigDecimal.ONE);
authTransaction.setCurrency(account.getCurrency());
authTransaction.setTransactionType(TransactionType.AUTHORIZE);
try {
accountApi.processPayment(account.getAccountId(), authTransaction, account.getPaymentMethodId(), NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
fail();
} catch (KillBillClientException e) {
assertEquals(504, e.getResponse().getStatusCode());
}
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPayment method testWithFailedPaymentAndScheduledAttemptsGetInvoicePayment.
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetInvoicePayment() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
// Getting Invoice #2 (first after Trial period)
UUID failedInvoiceId = accountApi.getInvoicesForAccount(account.getAccountId(), null, null, null, RequestOptions.empty()).get(1).getInvoiceId();
HashMultimap<String, String> queryParams = HashMultimap.create();
queryParams.put("withAttempts", "true");
RequestOptions inputOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).withQueryParams(queryParams).build();
InvoicePayments invoicePayments = invoiceApi.getPaymentsForInvoice(failedInvoiceId, inputOptions);
Assert.assertEquals(invoicePayments.get(0).getTargetInvoiceId(), failedInvoiceId);
Assert.assertNotNull(invoicePayments.get(0).getPaymentAttempts());
Assert.assertEquals(invoicePayments.get(0).getPaymentAttempts().size(), 2);
Assert.assertEquals(invoicePayments.get(0).getPaymentAttempts().get(0).getStateName(), "RETRIED");
Assert.assertEquals(invoicePayments.get(0).getPaymentAttempts().get(1).getStateName(), "SCHEDULED");
// Remove the future notification and check SCHEDULED does not appear any longer
paymentApi.cancelScheduledPaymentTransactionByExternalKey(invoicePayments.get(0).getPaymentAttempts().get(1).getTransactionExternalKey(), inputOptions);
invoicePayments = invoiceApi.getPaymentsForInvoice(failedInvoiceId, inputOptions);
Assert.assertEquals(invoicePayments.get(0).getPaymentAttempts().size(), 1);
Assert.assertEquals(invoicePayments.get(0).getPaymentAttempts().get(0).getStateName(), "RETRIED");
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPayment method testWithCanceledPayment.
@Test(groups = "slow")
public void testWithCanceledPayment() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
mockPaymentProviderPlugin.makeNextPaymentFailWithCancellation();
final PaymentTransaction authTransaction = new PaymentTransaction();
authTransaction.setAmount(BigDecimal.ONE);
authTransaction.setCurrency(account.getCurrency());
authTransaction.setTransactionType(TransactionType.AUTHORIZE);
final Payment payment = accountApi.processPayment(account.getAccountId(), authTransaction, account.getPaymentMethodId(), NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
final PaymentTransaction paymentTransaction = payment.getTransactions().get(0);
assertEquals(paymentTransaction.getStatus(), TransactionStatus.PLUGIN_FAILURE);
}
Aggregations