-1

I am testing with Stripe for my website.This is the script to create an account.

 require 'stripe'
 Stripe.api_key =  'sk_test_viztoDNoflBnvkVwr8QG9SPE'
 Stripe::Account.create(
  :country => "US",
  :managed => false,
  :email => "ra@stripe.com"
)

The ruby code is run in the terminal with the command

ruby stripe.rb

The command runs successfully . But I am not recieving the json response in the terminal. Can anyone tell me why?

raj
  • 5,989
  • 7
  • 30
  • 62
  • 1
    You will need to print the result to the console, try setting your create command to a variable and `puts` it to the console – Wargog Oct 21 '15 at 11:10
  • Have you tried using `puts`? – Drenmi Oct 21 '15 at 11:10
  • 1
    Well that was a stupid question. I should have tried `puts`. It worked. – raj Oct 21 '15 at 11:16
  • Unrelated to your question, but even if it's only a test key, you should not share secret API keys. I recommend you edit your message to replace your key with e.g. `"sk_test_..."` and roll out a new API key. (You can do so from your [dashboard](https://dashboard.stripe.com/account/apikeys) by clicking on the recycle icon next to each key). – Ywain Oct 21 '15 at 12:27

1 Answers1

0

When you run a command in the ruby console (irb) the console will always repeats back the return value of a command.

Ruby does not do that when you run a file with the ruby command. Instead your need to use puts or print to write to stdout.

require 'stripe'

Stripe.api_key =  'sk_test_viztoDNoflBnvkVwr8QG9SPE'
response = Stripe::Account.create(
  :country => "US",
  :managed => false,
  :email => "ra@stripe.com"
)
puts response
Community
  • 1
  • 1
max
  • 96,212
  • 14
  • 104
  • 165