Search in sources :

Example 61 with Account

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

the class TestPaymentGateway method testBuildFormDescriptor.

@Test(groups = "slow")
public void testBuildFormDescriptor() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
    final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = killBillClient.buildFormDescriptor(hppFields, account.getAccountId(), null, ImmutableMap.<String, String>of(), requestOptions);
    Assert.assertEquals(hostedPaymentPageFormDescriptor.getKbAccountId(), account.getAccountId());
}
Also used : Account(org.killbill.billing.client.model.Account) HostedPaymentPageFormDescriptor(org.killbill.billing.client.model.HostedPaymentPageFormDescriptor) HostedPaymentPageFields(org.killbill.billing.client.model.HostedPaymentPageFields) Test(org.testng.annotations.Test)

Example 62 with Account

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

the class TestPaymentGateway method testComboBuildFormDescriptor.

@Test(groups = "slow")
public void testComboBuildFormDescriptor() throws Exception {
    final Account account = getAccount();
    account.setAccountId(null);
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    final PaymentMethod paymentMethod = new PaymentMethod(null, UUID.randomUUID().toString(), null, true, PLUGIN_NAME, info);
    final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
    final ComboHostedPaymentPage comboHostedPaymentPage = new ComboHostedPaymentPage(account, paymentMethod, ImmutableList.<PluginProperty>of(), hppFields);
    final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = killBillClient.buildFormDescriptor(comboHostedPaymentPage, ImmutableMap.<String, String>of(), requestOptions);
    Assert.assertNotNull(hostedPaymentPageFormDescriptor.getKbAccountId());
}
Also used : Account(org.killbill.billing.client.model.Account) HostedPaymentPageFormDescriptor(org.killbill.billing.client.model.HostedPaymentPageFormDescriptor) HostedPaymentPageFields(org.killbill.billing.client.model.HostedPaymentPageFields) ComboHostedPaymentPage(org.killbill.billing.client.model.ComboHostedPaymentPage) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) Test(org.testng.annotations.Test)

Example 63 with Account

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

the class TestPaymentMethod method testSearchPaymentMethods.

@Test(groups = "slow", description = "Can search payment methods")
public void testSearchPaymentMethods() throws Exception {
    // Search random key
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
    // Create a payment method
    final List<PluginProperty> pmProperties = new ArrayList<PluginProperty>();
    pmProperties.add(new PluginProperty("CC_NAME", "Bozo", false));
    pmProperties.add(new PluginProperty("CC_CITY", "SF", false));
    pmProperties.add(new PluginProperty("CC_LAST_4", "4365", false));
    pmProperties.add(new PluginProperty("CC_STATE", "CA", false));
    pmProperties.add(new PluginProperty("CC_COUNTRY", "Zimbawe", false));
    final Account accountJson = createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), pmProperties);
    final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(accountJson.getPaymentMethodId(), true);
    // Search random key again
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
    // Last 4
    doSearch("4365", paymentMethodJson);
    // Name
    doSearch("Bozo", paymentMethodJson);
    // City
    doSearch("SF", paymentMethodJson);
    // State
    doSearch("CA", paymentMethodJson);
    // Country
    doSearch("Zimbawe", paymentMethodJson);
}
Also used : PluginProperty(org.killbill.billing.client.model.PluginProperty) Account(org.killbill.billing.client.model.Account) ArrayList(java.util.ArrayList) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) Test(org.testng.annotations.Test)

Example 64 with Account

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

the class TestPaymentMethod method testPaymentMethodCustomFields.

@Test(groups = "slow", description = "Can create, retrieve and delete custom fields")
public void testPaymentMethodCustomFields() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final UUID paymentMethodId = account.getPaymentMethodId();
    final CustomField customField = new CustomField();
    customField.setObjectId(paymentMethodId);
    customField.setObjectType(ObjectType.PAYMENT_METHOD);
    customField.setName("testKey");
    customField.setValue("testValue");
    // Create custom field
    final CustomFields createdCustomFields = killBillClient.createPaymentMethodCustomField(paymentMethodId, customField, createdBy, reason, comment);
    Assert.assertEquals(createdCustomFields.size(), 1);
    final CustomField createdCustomField = createdCustomFields.get(0);
    Assert.assertEquals(createdCustomField.getName(), "testKey");
    Assert.assertEquals(createdCustomField.getValue(), "testValue");
    Assert.assertEquals(createdCustomField.getObjectId(), paymentMethodId);
    Assert.assertEquals(createdCustomField.getObjectType(), ObjectType.PAYMENT_METHOD);
    // Retrieve custom field
    final CustomFields retrievedCustomFields = killBillClient.getPaymentMethodCustomFields(paymentMethodId, AuditLevel.NONE);
    Assert.assertEquals(retrievedCustomFields.size(), 1);
    final CustomField retrievedCustomField = retrievedCustomFields.get(0);
    Assert.assertEquals(retrievedCustomField.getName(), "testKey");
    Assert.assertEquals(retrievedCustomField.getValue(), "testValue");
    Assert.assertEquals(retrievedCustomField.getObjectId(), paymentMethodId);
    Assert.assertEquals(retrievedCustomField.getObjectType(), ObjectType.PAYMENT_METHOD);
    // Delete custom field
    killBillClient.deletePaymentMethodCustomFields(paymentMethodId, Collections.<UUID>singletonList(createdCustomField.getCustomFieldId()), createdBy, reason, comment);
    final CustomFields deletedCustomFields = killBillClient.getPaymentMethodCustomFields(paymentMethodId, AuditLevel.NONE);
    Assert.assertEquals(deletedCustomFields.size(), 0);
}
Also used : Account(org.killbill.billing.client.model.Account) CustomFields(org.killbill.billing.client.model.CustomFields) CustomField(org.killbill.billing.client.model.CustomField) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 65 with Account

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

the class TestTag method testTagsPagination.

@Test(groups = "slow", description = "Can paginate through all tags")
public void testTagsPagination() throws Exception {
    final Account account = createAccount();
    for (int i = 0; i < 5; i++) {
        final TagDefinition tagDefinition = new TagDefinition(null, false, UUID.randomUUID().toString().substring(0, 5), UUID.randomUUID().toString(), ImmutableList.<ObjectType>of(ObjectType.ACCOUNT));
        final UUID tagDefinitionId = killBillClient.createTagDefinition(tagDefinition, requestOptions).getId();
        killBillClient.createAccountTag(account.getAccountId(), tagDefinitionId, requestOptions);
    }
    final Tags allTags = killBillClient.getTags(requestOptions);
    Assert.assertEquals(allTags.size(), 5);
    Tags page = killBillClient.getTags(0L, 1L, requestOptions);
    for (int i = 0; i < 5; i++) {
        Assert.assertNotNull(page);
        Assert.assertEquals(page.size(), 1);
        Assert.assertEquals(page.get(0), allTags.get(i));
        page = page.getNext();
    }
    Assert.assertNull(page);
    for (final Tag tag : allTags) {
        doSearchTag(UUID.randomUUID().toString(), null);
        doSearchTag(tag.getTagId().toString(), tag);
        doSearchTag(tag.getTagDefinitionName(), tag);
        final TagDefinition tagDefinition = killBillClient.getTagDefinition(tag.getTagDefinitionId(), requestOptions);
        doSearchTag(tagDefinition.getDescription(), tag);
    }
    final Tags tags = killBillClient.searchTags(ObjectType.ACCOUNT.toString(), requestOptions);
    Assert.assertEquals(tags.size(), 5);
    Assert.assertEquals(tags.getPaginationCurrentOffset(), 0);
    Assert.assertEquals(tags.getPaginationTotalNbRecords(), 5);
    Assert.assertEquals(tags.getPaginationMaxNbRecords(), 5);
}
Also used : Account(org.killbill.billing.client.model.Account) TagDefinition(org.killbill.billing.client.model.TagDefinition) Tag(org.killbill.billing.client.model.Tag) UUID(java.util.UUID) SystemTags(org.killbill.billing.util.tag.dao.SystemTags) Tags(org.killbill.billing.client.model.Tags) 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