Skip to content

Instantly share code, notes, and snippets.

@jasocox
Created July 8, 2013 20:43
Show Gist options
  • Save jasocox/5952324 to your computer and use it in GitHub Desktop.
Save jasocox/5952324 to your computer and use it in GitHub Desktop.
Setting up the payout account
def setup_marketplace
api_key = Balanced::ApiKey.new.save
Balanced.configure api_key.secret
@marketplace = Balanced::Marketplace.new.save
# Add money to the account, so that it is useful...
card = @marketplace.create_card(
:card_number => "5105105105105100",
:expiration_month => "12",
:expiration_year => "2015"
)
@marketplace.create_buyer(
:email_address => 'buyer@example.org',
:card_uri => card.uri
).debit :amount => 10000000
end
def setup_merchant bank_account
merchant_attributes = {
:type => "person",
:name => "Billy Jones",
:street_address => "801 High St.",
:postal_code => "94301",
:country => "USA",
:dob => "1842-01",
:phone_number => "+16505551234",
}
merchant = Balanced::Account.new(
:uri => @marketplace.accounts_uri,
#:email_address => "merchant@example.org",
:merchant => merchant_attributes,
:bank_account_uri => bank_account.uri,
:name => "Jack Q Merchant"
).save
end
def setup_pending_merchant
@pending_account = @marketplace.create_bank_account(
:account_number => "021000021",
:routing_number => "9900000000",
:name => "Jack Q Merchant"
)
@pending_merchant = setup_merchant @pending_account
end
setup_pending_merchant
payout_uri = @pending_account.uri
bank_account = Balanced::BankAccount.find(payout_uri)
credit = Balanced::Credit.new(
:amount => (amount * 100).to_int,
:bank_account => bank_account.attributes
)
response = credit.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment