Using Stripe for Gift Certificates and Gift Subscriptions

Stripe is a terrific platform for processing payments. However, it does not automatically handle some common e-commerce features like gift certificates and gift subscriptions.

So, when implementing gift subscriptions on Cook Smarts, a Rails app, I found myself doing a lot of research.

We tried to use Stripe coupons as makeshift gift certificates, but the logic quickly fell apart, particularly when thinking about how a gift customer would become a paid customer.

Instead, we track gift subscriptions in Cook Smarts’ database, and use Stripe’s trial period feature to redeem them.

The end results:

  • I buy my friend a gift subscription.

  • She redeems the gift subscription, with no credit card required, and has access to Cook Smarts for the length of the gift.

  • If she wants to continue using Cook Smarts past the gift period, she can provide billing information at any time during the gift period, and she will become a paying customer at the end of the gift period.

Here’s how we did it.

When I buy my friend a gift subscription, the app creates a record in a gift subscriptions table. It includes a randomly-generated gift code and the length of the gift subscription.

When my friend redeems the gift subscription, the app marks it redeemed in the gift subscriptions table. It activates her subscription in Stripe, and includes a trial_end date, which tells Stripe the length of the gift period. Stripe does not require billing information for a free trial (or what we call the gift period).

customer = Stripe::Customer.create(
:email =>,
:plan => 'monthly',
:trial_end => gift_subscription.end_date #end_date is a method in the GiftSubscription model that returns the end date of the gift period, based upon the length of the gift subscription and the date it was redeemed

If my friend loves Cook Smarts and wants to continue as a paid member, she can provide billing information at any time during her gift period.  The app will pass the credit card, and her subscription choice, to Stripe, along with the same trial_end date. This way, she will continue on a gift subscription, and become a paying member at the end of it.

customer.update_subscription(:plan=> params[:selected_plan], :trial_end=>gift_subscription.end_date, :card => params[:stripe_token])

Stripe’s support team offered the following caution, consistent with the process above:

When you’re updating the customer’s subscription, you’ll want to make sure you’re explicitly passing in the trial_end parameter:

This will ensure that the trial will end on the date you pass in, otherwise the API will shift the trial end date based on the new plan you’re moving them to.

Basically, when the customer provides billing information and chooses a plan, we need to pass the original trial_end date as we do above, so that the customer is not charged until the end of the gift period.

All in all, it was fairly straight-forward to implement gift subscriptions with Stripe. The biggest hurdle was allowing customers to provide billing information at any time, while holding any charges until the end of the gift period. brings Rails job offers to you. Free for candidates. Salaries from $75,000 to $250,000. Sign up now!

Leave a Reply