Search in sources :

Example 11 with RequestOptions

use of org.killbill.billing.client.RequestOptions in project killbill by killbill.

the class TestPayment method testWithFailedPaymentAndScheduledAttemptsSearchPayments.

@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsSearchPayments() throws Exception {
    mockPaymentProviderPlugin.makeNextPaymentFailWithError();
    createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
    HashMultimap<String, String> queryParams = HashMultimap.create();
    queryParams.put("withAttempts", "true");
    RequestOptions inputOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).withQueryParams(queryParams).build();
    Payments payments = killBillClient.searchPayments("", 0L, 100L, AuditLevel.NONE, inputOptions);
    Assert.assertNotNull(payments.get(0).getPaymentAttempts());
    Assert.assertEquals(payments.get(0).getPaymentAttempts().get(0).getStateName(), "RETRIED");
    Assert.assertEquals(payments.get(0).getPaymentAttempts().get(1).getStateName(), "SCHEDULED");
}
Also used : RequestOptions(org.killbill.billing.client.RequestOptions) Payments(org.killbill.billing.client.model.Payments) InvoicePayments(org.killbill.billing.client.model.InvoicePayments) Test(org.testng.annotations.Test)

Example 12 with RequestOptions

use of org.killbill.billing.client.RequestOptions in project killbill by killbill.

the class TestPayment method testWithFailedPaymentAndWithoutFollowLocation.

@Test(groups = "slow")
public void testWithFailedPaymentAndWithoutFollowLocation() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    mockPaymentProviderPlugin.makeNextPaymentFailWithError();
    final PaymentTransaction authTransaction = new PaymentTransaction();
    authTransaction.setAmount(BigDecimal.ONE);
    authTransaction.setCurrency(account.getCurrency());
    authTransaction.setTransactionType(TransactionType.AUTHORIZE.name());
    final RequestOptions requestOptionsWithoutFollowLocation = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).withFollowLocation(false).build();
    try {
        killBillClient.createPayment(account.getAccountId(), account.getPaymentMethodId(), authTransaction, ImmutableMap.<String, String>of(), requestOptionsWithoutFollowLocation);
        fail();
    } catch (final KillBillClientException e) {
        assertEquals(e.getResponse().getStatusCode(), 402);
        assertEquals(e.getBillingException().getMessage(), "Payment decline by gateway. Error message: gatewayError");
    }
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Account(org.killbill.billing.client.model.Account) RequestOptions(org.killbill.billing.client.RequestOptions) KillBillClientException(org.killbill.billing.client.KillBillClientException) Test(org.testng.annotations.Test)

Aggregations

RequestOptions (org.killbill.billing.client.RequestOptions)12 Test (org.testng.annotations.Test)9 Account (org.killbill.billing.client.model.Account)5 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)4 UUID (java.util.UUID)3 Payments (org.killbill.billing.client.model.Payments)3 Tenant (org.killbill.billing.client.model.Tenant)3 BigDecimal (java.math.BigDecimal)2 KillBillClientException (org.killbill.billing.client.KillBillClientException)2 Payment (org.killbill.billing.client.model.Payment)2 PaymentTransaction (org.killbill.billing.client.model.PaymentTransaction)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Ehcache (net.sf.ehcache.Ehcache)1 AccountTimeline (org.killbill.billing.client.model.AccountTimeline)1 Catalog (org.killbill.billing.client.model.Catalog)1 ComboPaymentTransaction (org.killbill.billing.client.model.ComboPaymentTransaction)1 SimplePlan (org.killbill.billing.client.model.SimplePlan)1 Tags (org.killbill.billing.client.model.Tags)1 TenantKey (org.killbill.billing.client.model.TenantKey)1 TransactionType (org.killbill.billing.payment.api.TransactionType)1