Search in sources :

Example 66 with Account

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

the class TestTag method testNotAllowedSystemTag.

@Test(groups = "slow", description = "Can create a TagDefinition")
public void testNotAllowedSystemTag() throws Exception {
    final Account account = createAccount();
    try {
        killBillClient.createAccountTag(account.getAccountId(), SystemTags.PARK_TAG_DEFINITION_ID, requestOptions);
        Assert.fail("Creating a tag associated with a system tag should fail");
    } catch (final Exception e) {
        Assert.assertTrue(true);
    }
}
Also used : Account(org.killbill.billing.client.model.Account) KillBillClientException(org.killbill.billing.client.KillBillClientException) Test(org.testng.annotations.Test)

Example 67 with Account

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);
}
Also used : Account(org.killbill.billing.client.model.Account) ControlTagType(org.killbill.billing.util.tag.ControlTagType) TagDefinition(org.killbill.billing.client.model.TagDefinition) Subscription(org.killbill.billing.client.model.Subscription) DateTime(org.joda.time.DateTime) SystemTags(org.killbill.billing.util.tag.dao.SystemTags) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Example 68 with Account

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;
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Account(org.killbill.billing.client.model.Account) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Payment(org.killbill.billing.client.model.Payment) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod)

Example 69 with Account

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");
}
Also used : Account(org.killbill.billing.client.model.Account) Invoice(org.killbill.billing.client.model.Invoice) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Example 70 with Account

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");
}
Also used : Account(org.killbill.billing.client.model.Account) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Payment(org.killbill.billing.client.model.Payment) Test(org.testng.annotations.Test)

Aggregations

Account (org.killbill.billing.client.model.Account)123 Test (org.testng.annotations.Test)109 UUID (java.util.UUID)32 DateTime (org.joda.time.DateTime)32 Invoice (org.killbill.billing.client.model.Invoice)30 BigDecimal (java.math.BigDecimal)27 Payment (org.killbill.billing.client.model.Payment)24 Subscription (org.killbill.billing.client.model.Subscription)24 ComboPaymentTransaction (org.killbill.billing.client.model.ComboPaymentTransaction)17 InvoiceItem (org.killbill.billing.client.model.InvoiceItem)16 PaymentTransaction (org.killbill.billing.client.model.PaymentTransaction)16 KillBillClientException (org.killbill.billing.client.KillBillClientException)14 InvoicePayment (org.killbill.billing.client.model.InvoicePayment)14 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)13 PaymentMethod (org.killbill.billing.client.model.PaymentMethod)13 InvoicePaymentTransaction (org.killbill.billing.client.model.InvoicePaymentTransaction)10 Payments (org.killbill.billing.client.model.Payments)10 Tags (org.killbill.billing.client.model.Tags)10 Invoices (org.killbill.billing.client.model.Invoices)9 PaymentMethodPluginDetail (org.killbill.billing.client.model.PaymentMethodPluginDetail)9