Multiple Subscriptions
Creating a new subscription
Stripe offers the ability to subscribe a single customer object to multiple subscriptions. Each subscription will have a unique ID and its state is handled independently from other subscriptions. To add a new subscription to an existing customer, first retrieve the customer, and then use the create method within the subscriptions sublist:
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
Stripe::Subscription.create(
:customer => "cus_3R1W8PG2DmsmM9",
:plan => "basic_monthly"
)
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
stripe.Subscription.create(
customer="cus_3R1W8PG2DmsmM9",
plan="basic_monthly"
)
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
\Stripe\Subscription::create(array(
"customer" => "cus_3R1W8PG2DmsmM9",
"plan" => "basic_monthly"
));
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
stripe.subscriptions.create({
customer: "cus_3R1W8PG2DmsmM9",
plan: "basic_monthly"
}, function(err, subscription) {
// asynchronously called
});
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
Map<String, Object> subscriptionParams = new HashMap<String, Object>();
subscriptionParams.put("customer", "cus_3R1W8PG2DmsmM9");
subscriptionParams.put("plan", "basic_monthly");
Subscription.create(subscriptionParams);
A customer can be subscribed to a single plan more than once. The billing cycle for each subscription can be different, and is dependent on when that subscription was created.
Note that the number of trial days a customer has used is tracked on a per-subscription basis. We will deduct the number of trial days previously consumed by a subscription from the plan’s trial_period_days unless a trial_end value is specified.
Discounting a subscription
A coupon can be applied directly to the customer object, or on the subscription itself. A coupon applied at the customer object level will be applied to all recurring charges for that customer. However, a coupon applied at the subscription level will always take priority. An invoice can only have one coupon applied–it’s not possible to stack two or more coupons onto an invoice.