I am creating an application (based on an online resource). You can register or log in using the program. Then you can buy the product. Or make your own list and sell your products.
I integrate Stripe. When I create a Charge, I get this error in the console: Stripe::InvalidRequestError (Must provide source or customer.) .
Here is the order_controller.rb code for the charge action:
Stripe.api_key = ENV["STRIPE_API_KEY"] token = params[:stripeToken] begin charge = Stripe::Charge.create( :amount => (@listing.price * 100).floor, :currency => "usd", :card => token ) flash[:notice] = "Thanks for ordering!" rescue Stripe::CardError => e flash[:danger] = e.message end
Of course, I look at the Stripe API documentation here: Example download documentation and here: Download the full API description
I am not sure how to handle :resource or customer . I saw in other materials on the Internet that some people create a client. Other sites say :card out of date, so I'm a little confused.
I will leave the github repository of my project and feel free to take a look. I am also trying to deal with translations and recipients. Project repository
Thanks.
source share