Created
March 10, 2016 21:44
-
-
Save gpolyn/9bdb7839a2b309979083 to your computer and use it in GitHub Desktop.
attempting developers.dwolla.com/guides/transfer-money-between-users with dwolla_swagger gem
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 'dwolla_swagger' | |
require 'faker' | |
DwollaSwagger::Swagger.configure do |config| | |
config.host = 'api-uat.dwolla.com' | |
config.access_token = ENV['DWOLLA_UAT_ACCESS_TOKEN'] | |
end | |
# B | |
first = Faker::Name.first_name | |
last = Faker::Name.last_name | |
name = first + " " + last | |
p name | |
new_customer = DwollaSwagger::CustomersApi.create({:body => { | |
:firstName => first, | |
:lastName => last, | |
:email => Faker::Internet.email, | |
:ipAddress => Faker::Internet.ip_v4_address | |
}}) | |
# C | |
p "new_customer" | |
p new_customer | |
first = Faker::Name.first_name | |
last = Faker::Name.last_name | |
recipient = DwollaSwagger::CustomersApi.create({:body => { | |
:firstName => first, | |
:lastName => last, | |
:email => Faker::Internet.email, | |
:ipAddress => Faker::Internet.ip_v4_address | |
}}) | |
routingNumber = Faker::Number.number(9) | |
p routingNumber | |
accountNumber = Faker::Number.number(9) | |
p accountNumber | |
fs = DwollaSwagger::FundingsourcesApi.create_customer_funding_source(new_customer, {:body => { | |
:routingNumber => '222222226', | |
:accountNumber => '123456789', | |
:type => 'checking', | |
:name => name + " - Checking" | |
}}) | |
p "new funding source" | |
p fs | |
acct_fs = DwollaSwagger::FundingsourcesApi.get_customer_funding_sources(new_customer) | |
# p acct_fs[0].name # => "Vera Brittain’s Checking" | |
p acct_fs._embedded | |
transfer_request = { | |
:_links => { | |
:destination => {:href => recipient}, | |
:source => {:href => fs} | |
}, | |
:amount => {:currency => 'USD', :value => 225.00}, | |
:metadata => { | |
:customerId => 8675309, | |
:notes => 'For work completed on Sept. 1, 2015' | |
} | |
} | |
xfer = DwollaSwagger::TransfersApi.create({:body => transfer_request}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment