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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations