Search in sources :

Example 51 with Customer

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

the class InvoiceTest method testInvoiceRetrieveForCustomer.

@Test
public void testInvoiceRetrieveForCustomer() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("customer", customer.getId());
    listParams.put("count", 1);
    Invoice invoice = Invoice.all(listParams).getData().get(0);
    assertEquals(invoice.getCustomer(), customer.getId());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 52 with Customer

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

the class InvoiceTest method testInvoiceCreate.

@Test
public void testInvoiceCreate() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    Map<String, Object> invoiceItem = ImmutableMap.<String, Object>builder().put("customer", customer.getId()).put("amount", 100).put("currency", "usd").put("description", "my item").build();
    InvoiceItem createdItem = InvoiceItem.create(invoiceItem);
    assertEquals("my item", createdItem.getDescription());
    Invoice invoice = Invoice.create(ImmutableMap.<String, Object>builder().put("description", "my invoice").put("customer", customer.getId()).build());
    assertEquals("my invoice", invoice.getDescription());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 53 with Customer

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

the class InvoiceTest method testUpcomingInvoice.

@Test
public void testUpcomingInvoice() throws Exception {
    Customer customer = Customer.create(defaultCustomerParams);
    createDefaultInvoiceItem(customer);
    Map<String, Object> upcomingParams = new HashMap<String, Object>();
    upcomingParams.put("customer", customer.getId());
    Invoice upcomingInvoice = Invoice.upcoming(upcomingParams);
    assertFalse(upcomingInvoice.getAttempted());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 54 with Customer

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

the class InvoiceTest method testUpcomingInvoicePerCallAPIKey.

@Test
public void testUpcomingInvoicePerCallAPIKey() throws Exception {
    Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    createDefaultInvoiceItem(customer);
    Map<String, Object> upcomingParams = new HashMap<String, Object>();
    upcomingParams.put("customer", customer.getId());
    Invoice upcomingInvoice = Invoice.upcoming(upcomingParams, Stripe.apiKey);
    assertFalse(upcomingInvoice.getAttempted());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 55 with Customer

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

the class InvoiceTest method testInvoiceItemDelete.

@Test
public void testInvoiceItemDelete() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
    DeletedInvoiceItem deletedInvoiceItem = createdInvoiceItem.delete();
    assertTrue(deletedInvoiceItem.getDeleted());
    assertEquals(deletedInvoiceItem.getId(), createdInvoiceItem.getId());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) 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