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