Search in sources :

Example 46 with Customer

use of com.stripe.model.Customer in project stripe-java by stripe.

the class CustomerTest method testCustomerCreateWithShippingDetails.

@Test
public void testCustomerCreateWithShippingDetails() throws StripeException {
    ShippingDetails shippingDetails = new ShippingDetails();
    shippingDetails.setName("name");
    shippingDetails.setPhone("123-456-7890");
    Address address = new Address().setCity("Washington").setCountry("USA").setLine1("1600 Pennsylvania Ave.").setLine2("line 2 address").setPostalCode("20500").setState("D.C.");
    shippingDetails.setAddress(address);
    Map<String, Object> params = ImmutableMap.<String, Object>builder().putAll(defaultCustomerParams).put("shipping", ImmutableMap.builder().put("address", ImmutableMap.builder().put("line1", address.getLine1()).put("line2", address.getLine2()).put("city", address.getCity()).put("country", address.getCountry()).put("postal_code", address.getPostalCode()).put("state", address.getState()).build()).put("name", shippingDetails.getName()).put("phone", shippingDetails.getPhone()).build()).build();
    Customer customer = Customer.create(params);
    assertEquals(customer.getShipping(), shippingDetails);
}
Also used : Address(com.stripe.model.Address) Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) ShippingDetails(com.stripe.model.ShippingDetails) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 47 with Customer

use of com.stripe.model.Customer in project stripe-java by stripe.

the class CustomerTest method testCustomerUpdateToBlank.

@Test(expected = InvalidRequestException.class)
public void testCustomerUpdateToBlank() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "");
    createdCustomer.update(updateParams);
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 48 with Customer

use of com.stripe.model.Customer in project stripe-java by stripe.

the class InvoiceTest method testInvoiceItemCreatePerCallAPIKey.

@Test
public void testInvoiceItemCreatePerCallAPIKey() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    InvoiceItem invoiceItem = createDefaultInvoiceItem(customer);
    assertTrue(invoiceItem.getAmount() == 100);
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 49 with Customer

use of com.stripe.model.Customer in project stripe-java by stripe.

the class InvoiceTest method testInvoiceItemRetrieve.

@Test
public void testInvoiceItemRetrieve() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
    InvoiceItem retrievedInvoiceItem = InvoiceItem.retrieve(createdInvoiceItem.getId());
    assertEquals(createdInvoiceItem.getId(), retrievedInvoiceItem.getId());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 50 with Customer

use of com.stripe.model.Customer in project stripe-java by stripe.

the class InvoiceTest method testInvoiceListAndRetrieve.

@Test
public void testInvoiceListAndRetrieve() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("count", 1);
    listParams.put("subscription", customer.getSubscriptions().getData().get(0).getId());
    Invoice createdInvoice = Invoice.all(listParams).getData().get(0);
    Invoice retrievedInvoice = Invoice.retrieve(createdInvoice.getId());
    assertEquals(createdInvoice.getId(), retrievedInvoice.getId());
    InvoiceLineItemCollection lines = retrievedInvoice.getLines().all(listParams);
    assertNotNull(lines);
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) InvoiceLineItemCollection(com.stripe.model.InvoiceLineItemCollection) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

Customer (com.stripe.model.Customer)65 Test (org.junit.Test)63 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)60 HashMap (java.util.HashMap)40 DeletedCustomer (com.stripe.model.DeletedCustomer)24 ExternalAccount (com.stripe.model.ExternalAccount)16 Plan (com.stripe.model.Plan)16 Subscription (com.stripe.model.Subscription)15 DeletedExternalAccount (com.stripe.model.DeletedExternalAccount)13 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)10 InvoiceItem (com.stripe.model.InvoiceItem)10 Invoice (com.stripe.model.Invoice)7 Card (com.stripe.model.Card)6 DeletedSubscriptionItem (com.stripe.model.DeletedSubscriptionItem)5 SubscriptionItem (com.stripe.model.SubscriptionItem)5 BaseStripeTest (com.stripe.BaseStripeTest)3 BankAccount (com.stripe.model.BankAccount)3 DeletedBankAccount (com.stripe.model.DeletedBankAccount)3 ExternalAccountCollection (com.stripe.model.ExternalAccountCollection)3 Coupon (com.stripe.model.Coupon)2