Skip to content

Instantly share code, notes, and snippets.

@mjallday
Created January 22, 2014 16:25
Show Gist options
  • Save mjallday/8561837 to your computer and use it in GitHub Desktop.
Save mjallday/8561837 to your computer and use it in GitHub Desktop.
bank account payment example - ruby
require 'balanced'
# create an api key and marketplace for example purposes only.
# in real-life you only do this once by the dashboard.
api_key = Balanced::ApiKey.new.save
Balanced.configure(api_key.secret)
marketplace = Balanced::Marketplace.new.save
# create a bank account. this is normally done with balanced.js
bank_account = marketplace.create_bank_account(
:account_number => "1234567980",
:bank_code => "321174811",
:name => "Jack Q Merchant"
)
# create a new customer (this and the next step are optional)
customer = marketplace.create_customer(
:name => "Bill",
:email => "[email protected]",
:business_name => "Bill Inc.",
:ssn_last4 => "1234",
:address => {
:line1 => "1234 1st Street",
:city => "San Francisco",
:state => "CA"
}
).save
# associate the bank account with the customer
customer.add_bank_account(bank_account)
# pay the customer 25.00
bank_account.credit(
:amount => 2500,
:description => "new credit"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment