Search in sources :

Example 1 with PlanTransformUsage

use of com.stripe.model.PlanTransformUsage 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

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)1 DeletedPlan (com.stripe.model.DeletedPlan)1 Plan (com.stripe.model.Plan)1 PlanTransformUsage (com.stripe.model.PlanTransformUsage)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1