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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.