Search in sources :

Example 36 with Customer

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

the class CustomerTest method testCustomerUpdatePerCallAPIKey.

@Test
public void testCustomerUpdatePerCallAPIKey() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "Updated Description");
    Customer updatedCustomer = createdCustomer.update(updateParams, Stripe.apiKey);
    assertEquals(updatedCustomer.getDescription(), "Updated Description");
}
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 37 with Customer

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

the class CustomerTest method testCustomerDelete.

@Test
public void testCustomerDelete() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    DeletedCustomer deletedCustomer = createdCustomer.delete();
    Customer deletedRetrievedCustomer = Customer.retrieve(createdCustomer.getId());
    assertTrue(deletedCustomer.getDeleted());
    assertEquals(deletedCustomer.getId(), createdCustomer.getId());
    assertTrue(deletedRetrievedCustomer.getDeleted());
}
Also used : DeletedCustomer(com.stripe.model.DeletedCustomer) Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 38 with Customer

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

the class CustomerTest method testCustomerSourceUpdate.

@Test
public void testCustomerSourceUpdate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    ExternalAccountCollection customerSources = customer.getSources();
    ExternalAccount paymentSource = customerSources.getData().get(0);
    assert (paymentSource instanceof Card);
    Card card = (Card) paymentSource;
    HashMap<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("address_line1", "some address details");
    Card updatedCard = card.update(updateParams);
    assertEquals("some address details", updatedCard.getAddressLine1());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) HashMap(java.util.HashMap) ExternalAccountCollection(com.stripe.model.ExternalAccountCollection) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 39 with Customer

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

the class CustomerTest method testCustomerSourceRetrieveCard.

@Test
public void testCustomerSourceRetrieveCard() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    ExternalAccountCollection customerSources = customer.getSources();
    String paymentSourceId = customerSources.getData().get(0).getId();
    ExternalAccount paymentSource = customerSources.retrieve(paymentSourceId);
    assertNotNull(paymentSource);
    assertEquals(paymentSourceId, paymentSource.getId());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) ExternalAccountCollection(com.stripe.model.ExternalAccountCollection) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 40 with Customer

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

the class CustomerTest method testCustomerCreate.

@Test
public void testCustomerCreate() 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)

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