Search in sources :

Example 86 with Account

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

the class KillbillClient method createAccountWithDefaultPaymentMethod.

protected Account createAccountWithDefaultPaymentMethod(final String externalkey, @Nullable final List<PluginProperty> pmProperties) throws Exception {
    final Account input = createAccount();
    callbackServlet.pushExpectedEvent(ExtBusEventType.ACCOUNT_CHANGE);
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    info.setProperties(pmProperties);
    final PaymentMethod paymentMethodJson = new PaymentMethod(null, externalkey, input.getAccountId(), true, PLUGIN_NAME, info, EMPTY_AUDIT_LOGS);
    accountApi.createPaymentMethod(input.getAccountId(), paymentMethodJson, true, false, NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
    callbackServlet.assertListenerStatus();
    return accountApi.getAccount(input.getAccountId(), requestOptions);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) PaymentMethodPluginDetail(org.killbill.billing.client.model.gen.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.gen.PaymentMethod)

Example 87 with Account

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

the class KillbillClient method createSubscription.

protected Subscription createSubscription(final UUID accountId, final String bundleExternalKey, final String productName, final ProductCategory productCategory, final BillingPeriod billingPeriod) throws Exception {
    final Account account = accountApi.getAccount(accountId, requestOptions);
    // ANNUAL subscriptions are SUBSCRIPTION aligned
    if (billingPeriod == BillingPeriod.MONTHLY && (account.getBillCycleDayLocal() == null || account.getBillCycleDayLocal() == 0)) {
        callbackServlet.pushExpectedEvent(ExtBusEventType.ACCOUNT_CHANGE);
    }
    callbackServlet.pushExpectedEvents(ExtBusEventType.ENTITLEMENT_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.INVOICE_CREATION);
    final String externalKey = UUID.randomUUID().toString();
    final Subscription input = new Subscription();
    input.setAccountId(accountId);
    input.setBundleExternalKey(bundleExternalKey);
    input.setExternalKey(externalKey);
    input.setProductName(productName);
    input.setProductCategory(productCategory);
    input.setBillingPeriod(billingPeriod);
    input.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final Subscription subscription = subscriptionApi.createSubscription(input, null, null, true, false, false, true, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, NULL_PLUGIN_PROPERTIES, requestOptions);
    callbackServlet.assertListenerStatus();
    assertEquals(subscription.getExternalKey(), externalKey);
    if (bundleExternalKey != null) {
        assertEquals(subscription.getBundleExternalKey(), bundleExternalKey);
    }
    return subscription;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription)

Example 88 with Account

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

the class KillbillClient method getAccount.

public Account getAccount(final String name, final String externalKey, final String email, final UUID parentAccountId) {
    final UUID accountId = UUID.randomUUID();
    final int length = 4;
    final Currency currency = DEFAULT_CURRENCY;
    final String timeZone = "UTC";
    final String address1 = "12 rue des ecoles";
    final String address2 = "Poitier";
    final String postalCode = "44 567";
    final String company = "Renault";
    final String city = "Quelque part";
    final String state = "Poitou";
    final String country = "France";
    final String locale = "fr";
    final String phone = "81 53 26 56";
    final String notes = "notes";
    final boolean isPaymentDelegatedToParent = parentAccountId != null;
    // Note: the accountId payload is ignored on account creation
    return new Account(accountId, name, length, externalKey, email, null, currency, parentAccountId, isPaymentDelegatedToParent, null, null, timeZone, address1, address2, postalCode, company, city, state, country, locale, phone, notes, false, null, null, EMPTY_AUDIT_LOGS);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Currency(org.killbill.billing.catalog.api.Currency) UUID(java.util.UUID)

Example 89 with Account

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

the class TestAdmin method testAdminPaymentEndpoint.

@Test(groups = "slow")
public void testAdminPaymentEndpoint() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final String paymentExternalKey = "extkey";
    // Create Authorization
    final String authTransactionExternalKey = UUID.randomUUID().toString();
    final PaymentTransaction authTransaction = new PaymentTransaction();
    authTransaction.setAmount(BigDecimal.TEN);
    authTransaction.setCurrency(account.getCurrency());
    authTransaction.setPaymentExternalKey(paymentExternalKey);
    authTransaction.setTransactionExternalKey(authTransactionExternalKey);
    authTransaction.setTransactionType(TransactionType.AUTHORIZE);
    callbackServlet.pushExpectedEvent(ExtBusEventType.PAYMENT_SUCCESS);
    final Payment authPayment = accountApi.processPayment(account.getAccountId(), authTransaction, account.getPaymentMethodId(), NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
    callbackServlet.assertListenerStatus();
    fixPaymentState(authPayment, "AUTH_FAILED", "AUTH_FAILED", TransactionStatus.PAYMENT_FAILURE);
    final Payment updatedPayment = paymentApi.getPayment(authPayment.getPaymentId(), NULL_PLUGIN_PROPERTIES, requestOptions);
    Assert.assertEquals(updatedPayment.getTransactions().size(), 1);
    final PaymentTransaction authTransaction2 = updatedPayment.getTransactions().get(0);
    Assert.assertEquals(authTransaction2.getStatus(), TransactionStatus.PAYMENT_FAILURE);
    // Capture should fail because lastSuccessPaymentState was moved to AUTH_FAILED
    doCapture(updatedPayment, true);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.gen.PaymentTransaction) Account(org.killbill.billing.client.model.gen.Account) AdminPayment(org.killbill.billing.client.model.gen.AdminPayment) Payment(org.killbill.billing.client.model.gen.Payment) Test(org.testng.annotations.Test)

Example 90 with Account

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

the class TestBundle method testBundleFromAccount.

@Test(groups = "slow", description = "Can retrieve account bundles")
public void testBundleFromAccount() throws Exception {
    final Account accountJson = createAccount();
    createSubscription(accountJson.getAccountId(), "156567", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
    createSubscription(accountJson.getAccountId(), "265658", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
    final List<Bundle> objFromJson = accountApi.getAccountBundles(accountJson.getAccountId(), null, null, requestOptions);
    Assert.assertEquals(objFromJson.size(), 2);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Bundle(org.killbill.billing.client.model.gen.Bundle) 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