Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Charge card with stripe token returning nil

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am setting up my app with stripe and i am having a horrible time ha. I have spent close to 10 hours on it.
I finally realized that my token is returning nil.
The error on my logs is


On the second to last line, I am printing out the token but it is not returning anything. This is giving me




My create method is
``` [code=ruby]def create
     @order = Order.new(order_params)
     @listing = Listing.find(params[:listing_id])
     @seller = @listing.user

     @order.listing_id = @listing.id
     @order.buyer_id = current_user.id
     @order.seller_id = @seller.id

     Stripe.api_key ="sk_test_wCVovzzFUCYefEcIDpnCzcNq"
     token = params[:stripeToken]
 logger.debug "TOKEN IS: #{token}"

     begin
>>ERROR      charge = Stripe::Charge.create(
         :amount => (@listing.price * 100).floor,
         :currency => "usd",
         :source => token,
       )
       flash[:notice] = "Thanks for ordering!"
     rescue Stripe::CardError => e
       flash[:danger] = e.message
     end
     respond_to do |format|
       if @order.save
         format.html { redirect_to root_url, notice: "Thanks for ordering!" }
         format.json { render action: 'show', status: :created, location: @order }
       else
         format.html { render action: 'new' }
         format.json { render json: @order.errors, status: :unprocessable_entity }
       end
     end
   end
[code=ruby]

https://github.com/jeremiahlukus/Abound


I have been reading the docs and countless stackoverflow posts but everything I try does not seem to work.
Any help on this would be great. I know my API keys should be kept private however if I do not do it this way I get errors saying missing API key.
 
Jeremiah Parrack
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know how to edit the post, sorry about the unformatted method create.
 
Jeremiah Parrack
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
https://abound.herokuapp.com/
 
Jeremiah Parrack
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic