This gem will allow us to make requests to the Repay rest API from any project quickly
Add this line to your application’s Gemfile:
$ gem 'repay-rest-client-ruby', :git => 'https://github.com/ldstudios/repay_rest_client.git'
And then execute:
$ bundle
$ Repay::AchToken.new(customer_id, account_holder_name, routing_number, account_number, zip_code).ach_token
e.g.
$ Repay::AchToken.new("123", "Rick Sanchez", "121202221", "1234567812345678", "30506").ach_token
result will just be a string containing the ach_token returned from the API
-
you must have the following environment variables set:
-
REPAY_API_TOKEN
-
REPAY_REST_BASE
-
REPAY_SAVE_ACH_FORM_ID
-
REPAY_USE_STORED_ACH_FORM_ID
-
-
successful result should just be a string containing the ach_token returned from the API
-
unsuccessful result will be simply nil
$ Repay::AchTokenPayment.new(ach_token, customer_id, amount).payment
e.g.
$ Repay::AchTokenPayment.new("5068", "123", "2.22").payment
successful result will be a ruby hash parsed from JSON similar to this: “‘ruby
{"auth_code"=>"DEMO323", "details"=>nil, "message"=>"Approved - DEMO", "pn_ref"=>"148595274", "receipt_id"=>"148595274.VHJ9-OHFqYAelhdit-HmPPEKBtExcV3RMxlTEcZNL8jXZTXEKqVAI8kWx0-DqjvvTvyH0m1rzYRkfOBJ94SxHw", "description"=>nil, "code"=>"OK", "error"=>"APPROVED", "payment_method_detail"=> {"gateway_mid"=>"8638", "routing_number"=>"121202221", "bank_name"=>"", "name_on_check"=>"Jerry Smith", "account_last_four"=>"1812", "ach_account_type"=>"Checking"}, "success_data"=>[], "result"=>"0"}
“‘
unsuccessful result will be a ruby hash parsed from json similar to this: “‘ {“status”=>“error”, “errors”=>[{“description”=>“Decline - DEMO - ResultCode: 12 - AuthCode: ”, “name”=>“12”, “location”=>“gateway_error”}]} “`
-
you must have the following environment variables set:
-
REPAY_API_TOKEN
-
REPAY_REST_BASE
-
-
amount must be an even number when using a test repay setup
The gem is available as open source under the terms of the [MIT License](opensource.org/licenses/MIT).