Creating Subscription Plans

From Stripe’s perspective, a subscription is a relationship between a plan and a customer, both of which are data objects defined by the Stripe API. We need information about both plans and customers in our own database, so we’ll need analogs of both data objects.

As far as Stripe is concerned, a plan has the following parts:

  • An amount, which is what the user is charged per subscription term. In U.S. currency, the amount is in cents.

  • An id, which we’ll store in our database as remote_id to distinguish it from our local ActiveRecord database ID. This ID is generated by us; Stripe doesn’t care what it is, as long as it’s unique within our list of plans.

  • An interval and interval_count, which specify the length of the ...

Get Take My Money now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.