Skip to content

Commit

Permalink
Add support for Authorize.net duplicate window [#52 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed Jan 8, 2009
1 parent 612ef96 commit 2530eec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG = ActiveMerchant CHANGELOG


* Add support for Authorize.net duplicate window [Seamus Abshere]
* Return transaction id for PayPal refunds [jxtps435] * Return transaction id for PayPal refunds [jxtps435]
* Allow storage of e-checks with BraintreeGateway [jimiray] * Allow storage of e-checks with BraintreeGateway [jimiray]
* Add test URL to PayJunction gateway [boomtowndesigngroup] * Add test URL to PayJunction gateway [boomtowndesigngroup]
Expand Down
13 changes: 13 additions & 0 deletions lib/active_merchant/billing/gateways/authorize_net.rb
Expand Up @@ -33,6 +33,8 @@ class AuthorizeNetGateway < Gateway


self.arb_test_url = 'https://apitest.authorize.net/xml/v1/request.api' self.arb_test_url = 'https://apitest.authorize.net/xml/v1/request.api'
self.arb_live_url = 'https://api.authorize.net/xml/v1/request.api' self.arb_live_url = 'https://api.authorize.net/xml/v1/request.api'

class_inheritable_accessor :duplicate_window


APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4 APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4


Expand Down Expand Up @@ -86,6 +88,7 @@ def authorize(money, creditcard, options = {})
add_creditcard(post, creditcard) add_creditcard(post, creditcard)
add_address(post, options) add_address(post, options)
add_customer_data(post, options) add_customer_data(post, options)
add_duplicate_window(post)


commit('AUTH_ONLY', money, post) commit('AUTH_ONLY', money, post)
end end
Expand All @@ -103,6 +106,7 @@ def purchase(money, creditcard, options = {})
add_creditcard(post, creditcard) add_creditcard(post, creditcard)
add_address(post, options) add_address(post, options)
add_customer_data(post, options) add_customer_data(post, options)
add_duplicate_window(post)


commit('AUTH_CAPTURE', money, post) commit('AUTH_CAPTURE', money, post)
end end
Expand Down Expand Up @@ -319,6 +323,15 @@ def add_customer_data(post, options)
post[:customer_ip] = options[:ip] post[:customer_ip] = options[:ip]
end end
end end

# x_duplicate_window won't be sent by default, because sending it changes the response.
# "If this field is present in the request with or without a value, an enhanced duplicate transaction response will be sent."
# (as of 2008-12-30) http://www.authorize.net/support/AIM_guide_SCC.pdf
def add_duplicate_window(post)
unless duplicate_window.nil?
post[:duplicate_window] = duplicate_window
end
end


def add_address(post, options) def add_address(post, options)


Expand Down
14 changes: 14 additions & 0 deletions test/unit/gateways/authorize_net_test.rb
Expand Up @@ -73,6 +73,20 @@ def test_add_description
assert_equal 'My Purchase is great', result[:description] assert_equal 'My Purchase is great', result[:description]
end end


def test_add_duplicate_window_without_duplicate_window
result = {}
ActiveMerchant::Billing::AuthorizeNetGateway.duplicate_window = nil
@gateway.send(:add_duplicate_window, result)
assert_nil result[:duplicate_window]
end

def test_add_duplicate_window_with_duplicate_window
result = {}
ActiveMerchant::Billing::AuthorizeNetGateway.duplicate_window = 0
@gateway.send(:add_duplicate_window, result)
assert_equal 0, result[:duplicate_window]
end

def test_purchase_is_valid_csv def test_purchase_is_valid_csv
params = { :amount => '1.01' } params = { :amount => '1.01' }


Expand Down

0 comments on commit 2530eec

Please sign in to comment.