create_subscription: Create a subscription

View source: R/subscription.R

create_subscriptionR Documentation

Create a subscription

Description

Creates a subscription at Stripe and returns the newly created stripe_subscription object. See the stripe_subscription documentation for more information on the subscription object.

Usage

create_subscription(
  plan_id,
  customer_id,
  card_token = NULL,
  exp_month = NULL,
  exp_year = NULL,
  number = NULL,
  cvc = NULL,
  name = NULL,
  address_city = NULL,
  address_country = NULL,
  address_line1 = NULL,
  address_line2 = NULL,
  address_state = NULL,
  address_zip = NULL,
  currency = NULL,
  default_for_currency = NULL,
  card_metadata = list(),
  coupon = NULL,
  application_fee_percent = NULL,
  quantity = NULL,
  tax_percent = NULL,
  trial_end = NULL,
  trial_period_days = NULL
)

Arguments

plan_id

The identifier of the plan to subscribe the customer to.

customer_id

The identifier of the customer to subscribe.

card_token

The identifier of the card token that can be used for payment of the subscription

exp_month

Expiration month for the card to be used if card_token is not passed

exp_year

Expiration year for the card to be used if card_token is not passed

number

Card number for the card to be used if card_token is not passed

cvc

Card security code for the card to be used if card_token is not passed

name

Card holder name for the card to be used if card_token is not passed

address_city

City of the billing address for the card

address_country

Country of the billing address for the card

address_line1

Line 1 of billing address for the card

address_line2

Line 2 of billing address for the card

address_state

State from the billing address for the card

address_zip

Zip or Postal Code for card billing address

coupon

The code of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription

quantity

The quantity you'd like to apply to the subscription you're creating. For example, if your plan is 10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged 50 (5 x 10) monthly. If you update a subscription but don't change the plan ID (e.g. changing only the trial_end), the subscription will inherit the old subscription's quantity attribute unless you pass a new quantity parameter. If you update a subscription and change the plan ID, the new subscription will not inherit the quantity attribute and will default to 1 unless you pass a quantity parameter

tax_percent

A positive decimal (with at most four decimal places) between 1 and 100. This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount each billing period. For example, a plan which charges $10/month with a tax_percent of 20.0 will charge $12 per invoice

trial_end

Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, trial_end will override the default trial period of the plan the customer is being subscribed to

trial_period_days

Integer representing the number of trial period days before the customer is charged for the first time. If set, trial_period_days overrides the default trial period days of the plan the customer is being subscribed to.

Note

If the plan that the customer is being subscribed to requires payment, then the customer will either need to have an defined payment source, or a payment source (card token or card information) will need to be passed in the function.


MrDAndersen/stRipe documentation built on March 17, 2024, 7:25 p.m.