Search in sources :

Example 1 with Customer

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

the class CardTest method testCardMetadata.

@Test
public void testCardMetadata() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Map<String, Object> creationParams = new HashMap<String, Object>();
    creationParams.put("source", "tok_visa");
    testMetadata(customer.createCard(creationParams));
}
Also used : Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with Customer

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

the class CouponTest method testCustomerCreateWithCoupon.

@Test
public void testCustomerCreateWithCoupon() throws StripeException {
    Coupon coupon = Coupon.create(getUniqueCouponParams());
    Map<String, Object> customerWithCouponParams = new HashMap<String, Object>();
    customerWithCouponParams.put("coupon", coupon.getId());
    Customer customer = Customer.create(customerWithCouponParams);
    assertEquals(customer.getDiscount().getCoupon().getId(), coupon.getId());
    customer.deleteDiscount();
    assertNull(Customer.retrieve(customer.getId()).getDiscount());
}
Also used : Coupon(com.stripe.model.Coupon) DeletedCoupon(com.stripe.model.DeletedCoupon) HashMap(java.util.HashMap) Customer(com.stripe.model.Customer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with Customer

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

the class CustomerTest method testCustomerCreateWithPlanPerCallAPIKey.

@Test
public void testCustomerCreateWithPlanPerCallAPIKey() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    Customer customer = createDefaultCustomerWithPlan(plan);
    assertEquals(customer.getSubscriptions().getData().get(0).getPlan().getId(), plan.getId());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 4 with Customer

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

the class CustomerTest method testCustomerCreatePerCallAPIKey.

@Test
public void testCustomerCreatePerCallAPIKey() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
    assertEquals(customer.getDescription(), "J Bindings Customer");
    List<ExternalAccount> customerSources = customer.getSources().getData();
    assertEquals(1, customerSources.size());
    assertThat(customerSources.get(0), instanceOf(Card.class));
    assertEquals("4242", ((Card) customerSources.get(0)).getLast4());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with Customer

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

the class CustomerTest method testCustomerRetrieve.

@Test
public void testCustomerRetrieve() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Customer retrievedCustomer = Customer.retrieve(createdCustomer.getId());
    assertEquals(createdCustomer.getCreated(), retrievedCustomer.getCreated());
    assertEquals(createdCustomer.getId(), retrievedCustomer.getId());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) 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