Stripe charging card error

Hey Alex, I'm getting this funky error: Stripe::InvalidRequestError in OrdersController#create You must supply either a source or a customer id begin charge = Stripe::Charge.create( :amount => (@listing.price * 100).floor, :currency => "usd", :card => token Not quite sure what is going on, but I'm guessing (based on Stripe docs), that I'm missing a required parameter somewhere in my controller. What do you think? Is this something you had on your end? Cheers! Marko

Posted over 4 years ago by Marko
Posted over 4 years ago by Marko

But, now I'm getting a different error:
Stripe::InvalidRequestError in OrdersController#create

Insufficient funds in Stripe account. In test mode, you can add funds to your available balance (bypassing your pending balance) by creating a charge with 4000 0000 0000 0077 as the card number.

transfer = Stripe::Transfer.create(
:amount => (@listing.price * 95).floor,
:currency => "usd",
:recipient => @seller.recipient,


When I charge the card with that number error gave me, it works fine.
Maybe it is the reason because we are initiating the transfer right away, without receiving the funds on my Stripe account first?

What do you think?

Thanks man!
Marko

1
Posted over 4 years ago by Marko

Hm, and I just added require "stripe" line above the Stripe.api_key = ENV["STRIPE_API_KEY"] token = params[:stripeToken] lines in my controller, and it worked. :)

1
Posted over 4 years ago by Alex Yang

I'm glad it's working, but the cause of the error may have had to do with your Stripe setup. I'd check your Gemfile to make sure that you've added the 'stripe' gem properly. I'd also check that you've added the 'javascript_include_tag' line in your application layout file so that your app is able to connect to your Stripe account. You'll be able to see all the code to do this under the 'Notes' in the videos for the Etsydemo course.

If you have any other course-related troubleshooting questions in the future, please post them to the 'Discussion' section beneath the video. Thanks!

2
Posted over 4 years ago by Jenson Vaj

Marko, thanks. I inserted your code and it worked on my app. Thx.

1