1. Subscriptions
Documentation
  • Back to home
  • StripeKit
  • Installation
  • Getting Started
  • Choosing a Mode
  • Type Reference
  • Setup
    • Configuration
    • Timezones
    • Storage Adapter
    • Money and Currency
    • Error Handling
  • Stripe
    • Elements
  • Modules
    • Overview
    • Customers
      • Overview
      • List
      • Retrieve
      • Find or Create by Email
      • Create
      • Update
      • Sync
      • Delete
    • Payment Methods
      • Overview
      • Create Setup Intent
      • List
      • Attach
      • Detach
      • Set Default
      • Sync
    • Payments
      • Overview
      • Pay With Saved Method
      • Create
      • Retrieve
      • Confirm
      • Cancel
      • Sync
    • Checkout
      • Overview
      • Get
      • Create
      • Submit Fields
      • Apply Coupon
      • Mark Complete
    • Subscriptions
      • Overview
      • Create
      • Retrieve
      • Cancel
      • Resume
      • Toggle Collection Method
      • Update Fields
      • Apply Promotion Code
      • List By Customer
      • Find By Metadata
      • Sync
    • Invoices
      • Overview
      • Retrieve
      • List By Customer
      • List By Subscription
      • Pay With Saved Method
      • Void
      • Finalize
      • Sync
    • Coupons
      • Overview
      • Create
      • Validate
      • Apply To Subscription
      • List
      • Deactivate
    • Webhooks
      • Overview
      • Process
      • Events Reference
    • Sync
      • Overview
  1. Subscriptions

Create

$kit->subscriptions->create()#

Creates a new subscription for an existing customer.

Signature#

Parameters#

FieldTypeRequiredDescription
customerIdstringYesThe customer to subscribe.
priceIdstringYesThe Stripe Price to subscribe them to.
userIdstring|intNoYour own internal user ID, stamped on the returned record.
quantityintNo, defaults to 1Number of units of the price.
trialPeriodDaysintNoLength of a free trial before the first charge.
collectionMethod'charge_automatically'|'send_invoice'No, defaults to 'charge_automatically'Whether Stripe charges the default payment method automatically, or emails an invoice for manual payment.
daysUntilDueintOnly with send_invoiceDefaults to 7.
defaultPaymentMethodIdstringNoPayment method used for this subscription's charges.
promotionCodestringNoA Stripe promotion code ID (not a plain code string) applied at creation.
metadataarray<string,string>NoMerged with source: "stripekit".
fieldValuesarray<string,string>NoWritten into metadata as field_<key> and surfaced back as fieldValues on every subsequent read.

Example request#

Example response#

...Local fields shown assume timezone: 'Europe/Amsterdam' was configured on init.

Errors#

ExceptionWhen
StripeOperationErrorThe customer or price ID does not exist, the customer has no default payment method and one is required, or Stripe otherwise rejects the request.

Notes#

If a storage adapter is configured, the record is persisted via saveSubscription() immediately.
Note that promotionCode expects a Stripe promotion code ID, not the plain-text code a customer types in. To apply a code by its plain text, validate it first with $kit->coupons->validate(), which returns a stripePromotionCodeId you can use here or with applyPromotionCode().
Previous
Overview
Next
Retrieve
Built with