Skip to content

Commit

Permalink
Forte: Add sec_code attribute for echeck
Browse files Browse the repository at this point in the history
Allows passing in the sec_code attribute and defaults to WEB if one is not provided

See https://www.forte.net/devdocs/api_resources/forte_api_v2.htm#echeck

The attribute has been made required in the sandbox in advance of requiring it in production later this year.

Fixes: #3612

Unit:
20 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
22 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Closes #3640
  • Loading branch information
wsmoak authored and molbrown committed May 26, 2020
1 parent d3285a9 commit 1c4b108
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Element: Add card_present_code field [schwarzgeist] #3623
* Orbital: Add support for Level 3 fields [leila-alderman] #3639
* Firstdata: Strip newline characters from address [bittercoder] #3643
* Forte: add sec_code attribute for echeck [wsmoak] #3640

== Version 1.107.3 (May 8, 2020)
* Realex: Ignore IPv6 unsupported addresses [elfassy] #3622
Expand Down
13 changes: 7 additions & 6 deletions lib/active_merchant/billing/gateways/forte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def purchase(money, payment_method, options={})
post = {}
add_amount(post, money, options)
add_invoice(post, options)
add_payment_method(post, payment_method)
add_payment_method(post, payment_method, options)
add_billing_address(post, payment_method, options)
add_shipping_address(post, options)
post[:action] = 'sale'
Expand All @@ -36,7 +36,7 @@ def authorize(money, payment_method, options={})
post = {}
add_amount(post, money, options)
add_invoice(post, options)
add_payment_method(post, payment_method)
add_payment_method(post, payment_method, options)
add_billing_address(post, payment_method, options)
add_shipping_address(post, options)
post[:action] = 'authorize'
Expand All @@ -57,7 +57,7 @@ def credit(money, payment_method, options={})
post = {}
add_amount(post, money, options)
add_invoice(post, options)
add_payment_method(post, payment_method)
add_payment_method(post, payment_method, options)
add_billing_address(post, payment_method, options)
post[:action] = 'disburse'

Expand Down Expand Up @@ -151,21 +151,22 @@ def add_shipping_address(post, options)
post[:shipping_address][:physical_address][:locality] = address[:city] if address[:city]
end

def add_payment_method(post, payment_method)
def add_payment_method(post, payment_method, options)
if payment_method.respond_to?(:brand)
add_credit_card(post, payment_method)
else
add_echeck(post, payment_method)
add_echeck(post, payment_method, options)
end
end

def add_echeck(post, payment)
def add_echeck(post, payment, options)
post[:echeck] = {}
post[:echeck][:account_holder] = payment.name
post[:echeck][:account_number] = payment.account_number
post[:echeck][:routing_number] = payment.routing_number
post[:echeck][:account_type] = payment.account_type
post[:echeck][:check_number] = payment.number
post[:echeck][:sec_code] = options[:sec_code] || "WEB"
end

def add_credit_card(post, payment)
Expand Down
12 changes: 12 additions & 0 deletions test/remote/gateways/remote_forte_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def test_successful_purchase_with_echeck
response = @gateway.purchase(@amount, @check, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert_equal 'WEB', response.params['echeck']['sec_code']
end

def test_successful_purchase_with_echeck_with_more_options
options = {
sec_code: "PPD"
}

response = @gateway.purchase(@amount, @check, options)
assert_success response
assert_equal 'APPROVED', response.message
assert_equal 'PPD', response.params['echeck']['sec_code']
end

def test_failed_purchase_with_echeck
Expand Down

0 comments on commit 1c4b108

Please sign in to comment.