Search in sources :

Example 1 with Address

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);
}
Also used : Address(com.stripe.model.Address) ShippingDetails(com.stripe.model.ShippingDetails) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with Address

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

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)2 Address (com.stripe.model.Address)2 ShippingDetails (com.stripe.model.ShippingDetails)2 Test (org.junit.Test)2 Charge (com.stripe.model.Charge)1 Customer (com.stripe.model.Customer)1 DeletedCustomer (com.stripe.model.DeletedCustomer)1