Search in sources :

Example 1 with Plan

use of com.stripe.model.Plan 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 2 with Plan

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

the class InvoiceTest method testInvoiceRetrieveForCustomerPerCallAPIKey.

@Test
public void testInvoiceRetrieveForCustomerPerCallAPIKey() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    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, Stripe.apiKey).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 3 with Plan

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

the class InvoiceTest method testInvoiceListAndRetrievePerCallAPIKey.

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

Example 4 with Plan

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

the class PlanTest method testPlanDeletePerCallAPIKey.

@Test
public void testPlanDeletePerCallAPIKey() throws StripeException {
    Plan createdPlan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    DeletedPlan deletedPlan = createdPlan.delete(Stripe.apiKey);
    assertTrue(deletedPlan.getDeleted());
    assertEquals(deletedPlan.getId(), createdPlan.getId());
}
Also used : DeletedPlan(com.stripe.model.DeletedPlan) Plan(com.stripe.model.Plan) DeletedPlan(com.stripe.model.DeletedPlan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with Plan

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

the class PlanTest method testPlanCreateWithTransformUsage.

@Test
public void testPlanCreateWithTransformUsage() throws StripeException {
    Map<String, Object> productParams = new HashMap<String, Object>();
    productParams.put("name", "Bar");
    Map<String, Object> params = getUniquePlanParams();
    params.remove("name");
    params.put("nickname", "Foo");
    params.put("product", productParams);
    Map<String, Object> transformUsage = new HashMap<>();
    transformUsage.put("divide_by", 1000);
    transformUsage.put("round", "up");
    params.put("transform_usage", transformUsage);
    Plan plan = Plan.create(params);
    assertEquals(new Long(100), plan.getAmount());
    PlanTransformUsage planTransformUsage = plan.getTransformUsage();
    assertEquals(new Long(1000), planTransformUsage.getDivideBy());
    assertEquals("up", planTransformUsage.getRound());
}
Also used : PlanTransformUsage(com.stripe.model.PlanTransformUsage) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) DeletedPlan(com.stripe.model.DeletedPlan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

Plan (com.stripe.model.Plan)34 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)31 Test (org.junit.Test)31 HashMap (java.util.HashMap)21 Customer (com.stripe.model.Customer)16 DeletedPlan (com.stripe.model.DeletedPlan)14 Subscription (com.stripe.model.Subscription)11 Invoice (com.stripe.model.Invoice)5 CustomerSubscriptionCollection (com.stripe.model.CustomerSubscriptionCollection)2 DeletedCustomer (com.stripe.model.DeletedCustomer)1 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)1 InvoiceItem (com.stripe.model.InvoiceItem)1 InvoiceLineItemCollection (com.stripe.model.InvoiceLineItemCollection)1 PlanTier (com.stripe.model.PlanTier)1 PlanTransformUsage (com.stripe.model.PlanTransformUsage)1 SubscriptionCollection (com.stripe.model.SubscriptionCollection)1 SubscriptionItem (com.stripe.model.SubscriptionItem)1 UsageRecord (com.stripe.model.UsageRecord)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1