def create customer = current_user.stripe_customer source = Stripe::Source.create(token: params[:stripeToken]) customer.default_source = source customer.save begin Stripe::Subscription.create( customer: customer, plan: 'pro' ) current_user.assign_attributes(stripe_subscription_id: subscription.id) current_user.save redirect_to root_path, notice: 'Thanks for subscribing!' rescue Stripe::CardError => e flash.alert = e.message render action: :new end
(byebug) customer.default_source #<Stripe::Source:0x8200 id=src_1IF0owCNZVElf42nYAuFRW1v> JSON: { "id": "src_1IF0owCNZVElf42nYAuFRW1v", "object": "source", "amount": null,