Ask A Question

Notifications

You’re not receiving notifications from this thread.

Stripe payments course getting out of date

Justin Mullis asked in Site Feedback

Chris just wanted to mention that the Stripe master course is getting a little out of date (mostly just API changes on Stripe's end). Maybe a good idea to enable commenting on each section/video in the course so people can see there what they need to change.

To start, it looks like you can pass the Stripe token as the "source" when creating a customer. Passing it when creating a subscription gives me an invalid parameter error from the Stripe gem.

I updated my user.rb from

def stripe_customer
    if stripe_id?
        Stripe::Customer.retrieve(stripe_id)
    else
        stripe_customer = Stripe::Customer.create(email: email)
        update(stripe_id: stripe_customer.id)
        stripe_customer
    end
end

to

def stripe_customer(stripeToken = nil)
    if stripe_id?
        Stripe::Customer.retrieve(stripe_id)
    else
        stripe_customer = Stripe::Customer.create(email: email, source: stripeToken)
        update(stripe_id: stripe_customer.id)
        stripe_customer
    end
end

And then the controller code for subscription create goes from

customer = current_user.stripe_customer

subscription = customer.subscriptions.create(
    source: params[:stripeToken],
    plan: params[:plan]
)

to

customer = current_user.stripe_customer(params[:stripeToken])

subscription = Stripe::Subscription.create({
    customer: customer.id,
    items: [{plan: params[:plan]}],
})

I think the code is a little gross looking following the changes, since stripeToken needs to be passed to the model to create the Stripe customer. But its working now.

Reply

Yep, I'm working on a whole new version. Also going to include a shopping cart example!

I've been waiting a little bit to make sure that I cover any new API changes that they are making. I'm going to start recording the new version this week so it should be out shortly.

If only APIs didn't change... 😜

Reply

Ok excellent, can't wait for the new version!

Reply

Brilliant. I just happen to working on a project that needs to integrate payments. Looking forward to this.

Reply

Did this new video to include a shopping cart ever get released Chris?

Reply

@bradley Yeah, I redid the whole thing but turned it into a separate course: https://courses.gorails.com/payments-with-rails-master-class

Covers one-time payments with a shopping cart example and subscription billing, all of it SCA compatible.

Reply

Oh right, class. I’ll look at this now so. Recently bought your jumpstart pro app. Amazing stuff. Just trying to get my head around the stripe payments section and have a Single purchase product for potential users so they could have an e-commerce type shop under the SAAS app you’ve built. I’ll look at the tutorial now. Class. Thanks again.

Reply

👍 The course will definitely help explain how all the payments stuff works better. Especially now that it's crazy complicated with SCA.

I should make a quick tutorial on one-time payments with Jumpstart Pro, because that's what I'm doing for selling the Jumpstart Pro licenses after all. I'll try and squeeze a screencast in today if I can.

Reply

Yeah that’s be class. I had it working but was getting some issues with the stripe intent method when checking if the card existed for the user. A quick video would be class alright. But no worries anyway, I’m sure I’ll figure it from the master class video. Let us know if you get the screencast up anyway. Great vid to have to reference if needed.

Reply

Just wondering if you made that video last week Chris before I jump in and tackle it? I know it'll help me a lot if you got around to explaining it in a quick video. Cheers dude.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.