Skip to content

Instantly share code, notes, and snippets.

@matin
Created June 12, 2012 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matin/2914023 to your computer and use it in GitHub Desktop.
Save matin/2914023 to your computer and use it in GitHub Desktop.
require 'balanced'
# create a test marketplace
api_key = Balanced::ApiKey.new.save
Balanced.configure(api_key.secret)
marketplace = Balanced::Marketplace.new.save
# charge $100.00 on a card
buyer = Balanced::Account.new(
:email_address => "ekant@example.com",
:card => {
:card_number => "4111 1111 1111 1111",
:expiration_month => 12,
:expiration_year => 2014
}
).save
buyer.debit(10000, appears_on_statement_as = "Photography by Fred")
# underwrite seller as a merchant
merchant = Balanced::Account.new(
:email_address => "fnietzsche@example.com",
:name => "Friedrich Nietzche",
:street_address => "801 High St Ste 200",
:country_code => "USA",
:dob => "1844-10",
:bank_account => {
:name => "Fred Nietzsche",
:account_number => "204820239384",
:bank_code => "121042882"
}
).save
# pay the merchant $90.00 via next-day direct deposit
merchant.credit(9000)
# collect $10.00 marketplace fee
marketplace.owner_account.credit(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment