use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestTag method testGetAllTagsByType.
@Test(groups = "slow", description = "Can search all tags for an account")
public void testGetAllTagsByType() throws Exception {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
final Account account = createAccountWithDefaultPaymentMethod();
final Subscription subscriptionJson = createEntitlement(account.getAccountId(), "87544332", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, true);
for (final ControlTagType controlTagType : ControlTagType.values()) {
killBillClient.createAccountTag(account.getAccountId(), controlTagType.getId(), requestOptions);
}
final TagDefinition bundleTagDefInput = new TagDefinition(null, false, "bundletagdef", "nothing special", ImmutableList.<ObjectType>of());
final TagDefinition bundleTagDef = killBillClient.createTagDefinition(bundleTagDefInput, requestOptions);
killBillClient.createBundleTag(subscriptionJson.getBundleId(), bundleTagDef.getId(), requestOptions);
final Tags allBundleTags = killBillClient.getBundleTags(subscriptionJson.getBundleId(), AuditLevel.FULL, requestOptions);
Assert.assertEquals(allBundleTags.size(), 1);
final Tags allAccountTags = killBillClient.getAllAccountTags(account.getAccountId(), null, AuditLevel.FULL, requestOptions);
Assert.assertEquals(allAccountTags.size(), ControlTagType.values().length + 1);
final Tags allBundleTagsForAccount = killBillClient.getAllAccountTags(account.getAccountId(), ObjectType.BUNDLE.name(), AuditLevel.FULL, requestOptions);
Assert.assertEquals(allBundleTagsForAccount.size(), 1);
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestTenantKV method createComboPaymentTransaction.
private Payment createComboPaymentTransaction(final RequestOptions requestOptions) throws KillBillClientException {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
info.setProperties(null);
final String paymentMethodExternalKey = UUID.randomUUID().toString();
final PaymentMethod paymentMethodJson = new PaymentMethod(null, paymentMethodExternalKey, null, true, PLUGIN_NAME, info);
final String authTransactionExternalKey = UUID.randomUUID().toString();
final PaymentTransaction authTransactionJson = new PaymentTransaction();
authTransactionJson.setAmount(BigDecimal.TEN);
authTransactionJson.setCurrency(accountJson.getCurrency());
authTransactionJson.setPaymentExternalKey(UUID.randomUUID().toString());
authTransactionJson.setTransactionExternalKey(authTransactionExternalKey);
authTransactionJson.setTransactionType("AUTHORIZE");
final ComboPaymentTransaction comboAuthorization = new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of());
final Payment payment = killBillClient.createPayment(comboAuthorization, ImmutableMap.<String, String>of(), requestOptions);
Assert.assertEquals(payment.getTransactions().get(0).getStatus(), TransactionStatus.SUCCESS.toString());
return payment;
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestOverdue method testExclusionControlTagOverdueConfig.
@Test(groups = "slow", description = "Allow overdue condition by exclusion control tag defined in overdue config xml file")
public void testExclusionControlTagOverdueConfig() throws Exception {
final String overdueConfigPath = Resources.getResource("overdueWithExclusionControlTag.xml").getPath();
killBillClient.uploadXMLOverdueConfig(overdueConfigPath, requestOptions);
// Create an account without a payment method and assign a TEST tag
final Account accountJson = createAccountNoPMBundleAndSubscription();
final Tags accountTag = killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.TEST.getId(), requestOptions);
assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.TEST.getId());
// Create an account without a TEST tag
final Account accountJsonNoTag = createAccountNoPMBundleAndSubscription();
// move a month a wait for invoicing
// No payment will be triggered as the account doesn't have a payment method
clock.addMonths(1);
crappyWaitForLackOfProperSynchonization();
// Get the invoices
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final List<Invoice> invoicesNoTag = killBillClient.getInvoicesForAccount(accountJsonNoTag.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoicesNoTag.size(), 2);
// We're still clear - see the configuration
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getIsClearState());
clock.addDays(30);
crappyWaitForLackOfProperSynchonization();
// This account is not expected to move to OD1 state because it does not match with exclusion controlTag defined
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
// This account is expected to move to OD1 state because it matches with exclusion controlTag defined
Assert.assertEquals(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getName(), "OD1");
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestPayment method testComboAuthorization.
@Test(groups = "slow")
public void testComboAuthorization() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
final Payment payment = killBillClient.createPayment(comboPaymentTransaction, ImmutableMap.<String, String>of(), requestOptions);
verifyComboPayment(payment, paymentExternalKey, BigDecimal.TEN, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
// Void payment using externalKey
final String voidTransactionExternalKey = UUID.randomUUID().toString();
final Payment voidPayment = killBillClient.voidPayment(null, paymentExternalKey, voidTransactionExternalKey, null, ImmutableMap.<String, String>of(), requestOptions);
verifyPaymentTransaction(accountJson, voidPayment.getPaymentId(), paymentExternalKey, voidPayment.getTransactions().get(1), voidTransactionExternalKey, null, "VOID", "SUCCESS");
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestInvoice method testInvoiceTransferCreditAccountNoCredit.
@Test(groups = "slow", description = "Fail to transfer credit from an account without parent account", expectedExceptions = KillBillClientException.class, expectedExceptionsMessageRegExp = ".* does not have credit")
public void testInvoiceTransferCreditAccountNoCredit() throws Exception {
final Account parentAccount = createAccount();
final Account childAccount = createAccount(parentAccount.getAccountId());
// transfer credit to parent account
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), requestOptions);
}
Aggregations