(888) 475-FLOW(3569)

Payments Ruby

Payments Ruby
# Add a card

require 'flowcommerce'

ORG = 'playground'
client = FlowCommerce.instance(:token => 'HlGgfflLamiTQJ')

card = client.cards.post(ORG,
 ::Io::Flow::V0::Models::CardForm.new(
 :number => "4012888888881881",
 :name => "Joe Smith",
 :expiration_month => 1,
 :expiration_year => 2020,
 :cvv => "737"
 )
 )

puts "Card created - secure token is: %s" % card.token
 
auth = client.authorizations.post(ORG,
 ::Io::Flow::V0::Models::MerchantOfRecordAuthorizationForm.new(
 :order_number => 'R726941',
 :token => card.token
 )
 )

puts "Authorization created for %s %s [id: %s]" % [auth.amount, auth.currency, auth.id]

capture = client.captures.post(ORG,
 ::Io::Flow::V0::Models::CaptureForm.new(
 :authorization_id => auth.id
 ))
puts "Capture created for %s %s [id: %s]" % [capture.amount, capture.currency, capture.id]