This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Charge card with stripe token returning nil

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://abound.herokuapp.com/
 
Jeremiah Parrack
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic