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