Search in sources :

Example 1 with Account

use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.

the class KillbillClient method createAccount.

protected Account createAccount(final UUID parentAccountId) throws Exception {
    callbackServlet.pushExpectedEvent(ExtBusEventType.ACCOUNT_CREATION);
    final Account account = createAccountNoEvent(parentAccountId);
    callbackServlet.assertListenerStatus();
    return account;
}
Also used : Account(org.killbill.billing.client.model.gen.Account)

Example 2 with Account

use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.

the class KillbillClient method createAccountWithExternalPMBundleAndSubscriptionAndManualPayTagAndWaitForFirstInvoice.

protected Account createAccountWithExternalPMBundleAndSubscriptionAndManualPayTagAndWaitForFirstInvoice() throws Exception {
    final Account accountJson = createAccountWithExternalPaymentMethod();
    assertNotNull(accountJson);
    callbackServlet.pushExpectedEvent(ExtBusEventType.TAG_CREATION);
    final Tags accountTag = accountApi.createAccountTags(accountJson.getAccountId(), ImmutableList.<UUID>of(ControlTagType.MANUAL_PAY.getId()), requestOptions);
    callbackServlet.assertListenerStatus();
    assertNotNull(accountTag);
    assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.MANUAL_PAY.getId());
    // Add a bundle, subscription and move the clock to get the first invoice
    final Subscription subscriptionJson = createSubscription(accountJson.getAccountId(), UUID.randomUUID().toString(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
    assertNotNull(subscriptionJson);
    callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION);
    clock.addDays(32);
    callbackServlet.assertListenerStatus();
    return accountJson;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription) Tags(org.killbill.billing.client.model.Tags)

Example 3 with Account

use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.

the class KillbillClient method createAccountWithExternalPaymentMethod.

protected Account createAccountWithExternalPaymentMethod() throws Exception {
    final Account input = createAccount();
    createPaymentMethod(input, true);
    return accountApi.getAccount(input.getAccountId(), requestOptions);
}
Also used : Account(org.killbill.billing.client.model.gen.Account)

Example 4 with Account

use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.

the class KillbillClient method createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice.

protected Account createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice() throws Exception {
    // Create an account with no payment method
    final Account accountJson = createAccount();
    assertNotNull(accountJson);
    // Add a bundle, subscription and move the clock to get the first invoice
    final Subscription subscriptionJson = createSubscription(accountJson.getAccountId(), UUID.randomUUID().toString(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
    assertNotNull(subscriptionJson);
    // No payment will be triggered as the account doesn't have a payment method
    callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION, ExtBusEventType.INVOICE_PAYMENT_FAILED);
    clock.addMonths(1);
    callbackServlet.assertListenerStatus();
    return accountJson;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription)

Example 5 with Account

use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.

the class TestAccountEmail method testAddAndRemoveAccountEmail.

@Test(groups = "slow", description = "Can create and delete account emails")
public void testAddAndRemoveAccountEmail() throws Exception {
    final Account input = createAccount();
    final UUID accountId = input.getAccountId();
    final String email1 = UUID.randomUUID().toString();
    final String email2 = UUID.randomUUID().toString();
    final AccountEmail accountEmailJson1 = new AccountEmail(accountId, email1, null);
    final AccountEmail accountEmailJson2 = new AccountEmail(accountId, email2, null);
    // Verify the initial state
    final List<AccountEmail> firstEmails = accountApi.getEmails(accountId, requestOptions);
    Assert.assertEquals(firstEmails.size(), 0);
    // Add an email
    accountApi.addEmail(accountId, accountEmailJson1, requestOptions);
    // Verify we can retrieve it
    final List<AccountEmail> secondEmails = accountApi.getEmails(accountId, requestOptions);
    Assert.assertEquals(secondEmails.size(), 1);
    Assert.assertEquals(secondEmails.get(0).getAccountId(), accountId);
    Assert.assertEquals(secondEmails.get(0).getEmail(), email1);
    // Add another email
    accountApi.addEmail(accountId, accountEmailJson2, requestOptions);
    // Verify we can retrieve both
    final List<AccountEmail> thirdEmails = accountApi.getEmails(accountId, requestOptions);
    Assert.assertEquals(thirdEmails.size(), 2);
    Assert.assertEquals(thirdEmails.get(0).getAccountId(), accountId);
    Assert.assertEquals(thirdEmails.get(1).getAccountId(), accountId);
    Assert.assertTrue(thirdEmails.get(0).getEmail().equals(email1) || thirdEmails.get(0).getEmail().equals(email2));
    Assert.assertTrue(thirdEmails.get(1).getEmail().equals(email1) || thirdEmails.get(1).getEmail().equals(email2));
    // Delete the first email
    accountApi.removeEmail(accountId, accountEmailJson1.getEmail(), requestOptions);
    // Verify it has been deleted
    final List<AccountEmail> fourthEmails = accountApi.getEmails(accountId, requestOptions);
    Assert.assertEquals(fourthEmails.size(), 1);
    Assert.assertEquals(fourthEmails.get(0).getAccountId(), accountId);
    Assert.assertEquals(fourthEmails.get(0).getEmail(), email2);
    // Try to add the same email
    accountApi.addEmail(accountId, accountEmailJson2, requestOptions);
    Assert.assertEquals(accountApi.getEmails(accountId, requestOptions), fourthEmails);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) AccountEmail(org.killbill.billing.client.model.gen.AccountEmail) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Aggregations

Account (org.killbill.billing.client.model.gen.Account)153 Test (org.testng.annotations.Test)139 DateTime (org.joda.time.DateTime)43 UUID (java.util.UUID)38 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)37 Subscription (org.killbill.billing.client.model.gen.Subscription)34 Invoice (org.killbill.billing.client.model.gen.Invoice)33 BigDecimal (java.math.BigDecimal)29 Payment (org.killbill.billing.client.model.gen.Payment)28 PaymentTransaction (org.killbill.billing.client.model.gen.PaymentTransaction)21 KillBillClientException (org.killbill.billing.client.KillBillClientException)19 Invoices (org.killbill.billing.client.model.Invoices)19 ComboPaymentTransaction (org.killbill.billing.client.model.gen.ComboPaymentTransaction)19 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)19 LocalDate (org.joda.time.LocalDate)13 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)13 Tags (org.killbill.billing.client.model.Tags)13 PaymentMethod (org.killbill.billing.client.model.gen.PaymentMethod)12 InvoicePaymentTransaction (org.killbill.billing.client.model.gen.InvoicePaymentTransaction)11 Payments (org.killbill.billing.client.model.Payments)10