Their API within their Docs should be the latest ways of handling changes. Was this all from the same request? It's really strange that the source in the first image doesn't match the source ID from the byebug.
With byebuy enabled, and once it gets triggered, head over to stripe to see if you can look up the source that was created before it is assigned to the customer.
And honestly, I would still really recommend checking out Stripe Checkout. It is so much easier to work with than the Payments API. I would only recommend the Payments API if you are dead set on having a single experience. And, personally, I have some assurance feeling knowing that I'm entering my card details on Stripe's website itself and not through the Payments API as I cannot always trust how a website is handling that information.
☒ in the subscriptions_controller.rb you can create a method to look up the plan. Something like
def selected_plan
plan = Plan.find(params[:plan])
plan.plan_code
end
And plan_code would be pro, annual, or whatever else that matches the plan ID within Stripe.
Then in the controller action, you would reference this selected_plan method in place of where 'pro' is in the episode.
Since Stripe has the list of plans, you need to have some awareness of what these plan ids are. Typically they will be fairly static within your application. So, you could set a global variable with an array of the plans. Something like
And wherever you need to loop over your available plans, then you can reference this global variable. This does limit you to having to deploy and make code changes for any new plans, but that could be a non-issue.