use of com.stripe.model.Address in project stripe-java by stripe.
the class ChargeTest method testChargeCreateWithShippingDetails.
@Test
public void testChargeCreateWithShippingDetails() 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(defaultChargeParams).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();
Charge createdCharge = Charge.create(params);
assertEquals(createdCharge.getShipping(), shippingDetails);
}
use of com.stripe.model.Address 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);
}
Aggregations