public class

StripePlanClient

extends Object
java.lang.Object
   ↳ com.wsl.modules.stripe.client.StripePlanClient

Class Overview

Encapsulates Plan-related Stripe API calls.

Summary

Public Constructors
StripePlanClient()
Public Methods
Plan createPlan(String id, int amount, String currency, String interval, int intervalCount, String planName, int trialPeriodDays, String statementDescriptor, Map<String, Object> metadata)
Create a Plan
Object deletePlan(String id)
Delete a Plan
PlanCollection listAllPlans(String createdTimestamp, TimeRange created, String endingBefore, int limit, String startingAfter)
List All Plans
Plan retrievePlan(String id)
Retrieve a Plan
Plan updatePlan(String id, String planName, String statementDescriptor, Map<String, Object> metadata)
Update a Plan
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public StripePlanClient ()

Public Methods

public Plan createPlan (String id, int amount, String currency, String interval, int intervalCount, String planName, int trialPeriodDays, String statementDescriptor, Map<String, Object> metadata)

Create a Plan

Parameters
id Unique string of your choice that will be used to identify this plan when subscribing a customer. This could be an identifier like "gold" or a primary key from your own database.
amount A positive integer in cents (or 0 for a free plan) representing how much to charge (on a recurring basis).
currency 3-letter ISO code for currency.
interval Specifies billing frequency. Either day, week, month or year.
intervalCount The number of intervals between each subscription billing. For example, interval=month and interval_count=3 bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
planName Name of the plan, to be displayed on invoices and in the web interface.
trialPeriodDays Specifies a trial period in (an integer number of) days. If you include a trial period, the customer won't be billed for the first time until the trial period ends. If the customer cancels before the trial period is over, she'll never be billed at all.
statementDescriptor An arbitrary string to be displayed on your customer's credit card statement. This may be up to22 characters.
metadata A set of key/value pairs that you can attach to a plan object. It can be useful for storing additional information about the plan in a structured format.
Returns
  • Plan the created Plan
Throws
StripeConnectorException when there is an issue creating a Plan

public Object deletePlan (String id)

Delete a Plan

Parameters
id The id of the plan to delete
Returns
  • Object JSON containing success or failure
Throws
StripeConnectorException when there is an issue deleting a Plan

public PlanCollection listAllPlans (String createdTimestamp, TimeRange created, String endingBefore, int limit, String startingAfter)

List All Plans

Parameters
createdTimestamp A filter on the list based on the object created field. The value can be a string with an integer Unix timestamp.
created A filter on the list based on the object created field. The value can be a dictionary containing gt, gte, lt and/or lte values. You cannot supply a created value and this dictionary at the same time.
endingBefore A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_bar, your subsequent call can include ending_before=obj_bar in order to fetch the previous page of the list.
limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items.
startingAfter A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch the next page of the list.
Returns
  • PlanCollection the plans that matched the criteria
Throws
StripeConnectorException when there is an issue listing plans

public Plan retrievePlan (String id)

Retrieve a Plan

Parameters
id The id of the plan to retrieve
Returns
  • Plan the retrieved Plan
Throws
StripeConnectorException when there is an issue retrieving a Plan

public Plan updatePlan (String id, String planName, String statementDescriptor, Map<String, Object> metadata)

Update a Plan

Parameters
id Of the plan to update
planName Name of the plan, to be displayed on invoices and in the web interface.
statementDescriptor An arbitrary string to be displayed on your customer's credit card statement. This may be up to22 characters.
metadata A set of key/value pairs that you can attach to a plan object. It can be useful for storing additional information about the plan in a structured format.
Returns
  • Plan the updated Plan
Throws
StripeConnectorException when there is an issue updating a Plan