Created
January 22, 2014 16:25
-
-
Save mjallday/8561837 to your computer and use it in GitHub Desktop.
bank account payment example - ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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