From af1bcf05ea19e4e6bb6e7cae92e54f050cc4af67 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 22 Feb 2018 14:58:54 -0600 Subject: [PATCH] initialize stripe sub for returning subs --- app/controllers/subscriptions_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index c972112d..75f3cb0f 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -68,6 +68,11 @@ class SubscriptionsController < ApplicationController stripe_customer = Stripe::Customer.retrieve current_user.stripe_customer_id stripe_subscription = stripe_customer.subscriptions.data[0] + if stripe_subscription.nil? + Stripe::Subscription.create(customer: current_user.stripe_customer_id, plan: 'starter') + stripe_subscription = stripe_customer.subscriptions.data[0] + end + # If the user already has a payment method on file, change their plan and add a new subscription if stripe_customer.sources.total_count > 0 # Cancel any active subscriptions, since we're changing plans