Purchasing a Subscription

The workflow for purchasing a subscription is similar to purchasing an individual item, but there are also differences. On the client page, the user selects a subscription plan and enters his or her credit card information. As before, our application contacts Stripe from the client browser before the form is submitted and we receive a token. Also as before, we take that token and send it back to our server when the credit card form is finished.

From this point on, the server-side logic for a subscription purchase differs. Instead of sending a Stripe Purchase object to Stripe, a Customer object is created and associated with the token, which represents the payment method and our user. Now the subscription transaction ...

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.