Last active
August 29, 2015 14:13
-
-
Save pootsbook/0ba1c0d54a2c019ad51a to your computer and use it in GitHub Desktop.
Balanced ACH Account Creation
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
# gem 'balanced', '1.2.1' | |
# BalancedPayments API v1.1 | |
# ACH Payments only | |
# Three parties: marketplace (you), merchant (Balanced::Customer), buyer (Balanced::Customer) | |
bank_account_href = "" # from balanced.js | |
bank_account = Balanced::BankAccount.fetch(bank_href) | |
# it seems a customer requires dob_month, dob_year & address.postal_code in order to be verified | |
# cf. https://docs.balancedpayments.com/1.1/overview/resources/#customer-identity-verification | |
customer = Balanced::Customer.new(name: "Henry Ford", dob_month: 07, dob_year: 1985, address: { postal_code: '48120' }).save | |
bank_account.associate_to_customer(customer.href) | |
# buyer accounts need to be verified to debit | |
verification = bank_account.verify | |
verification.confirm(amount_1 = 1, amount_2 = 1) | |
# create an order | |
order = merchant.create_order(description: "Invoice #101") | |
# debit buyer | |
buyer_debit = order.debit_from(source: buyer_bank_account, amount: 100_00) | |
# credit merchant | |
merchant_credit = order.credit_to(destination: merchant_bank_account, amount: 90_00) | |
# credit marketplace | |
marketplace_credit = order.credit_to(destination: marketplace_bank_account, amount: 10_00) | |
# settle funds to merchant | |
account = merchant.payable_account | |
account.settle(funding_instrument: merchant_bank_account) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment