Skip to content

Commit

Permalink
Provide a C_STATE value of 'Outside United States' for SageGateway wh…
Browse files Browse the repository at this point in the history
…en processing international customers
  • Loading branch information
Cody Fauser committed Oct 6, 2009
1 parent 411046a commit 39e6eb0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Provide a C_STATE value of "Outside United States" for SageGateway when processing international customers [cody]
* PayPal Website Payments Pro Canada supports Amex [cody]
* Add line item support for LinkpointGateway. [Tony Primerano]
* Add support for SallieMae gateway [iamjwc]
Expand Down
8 changes: 7 additions & 1 deletion lib/active_merchant/billing/gateways/sage/sage_core.rb
Expand Up @@ -55,7 +55,13 @@ def add_addresses(post, options)

post[:C_address] = billing_address[:address1]
post[:C_city] = billing_address[:city]
post[:C_state] = billing_address[:state]

if ['US', 'CA'].include?(billing_address[:country])
post[:C_state] = billing_address[:state]
else
post[:C_state] = "Outside of United States"
end

post[:C_zip] = billing_address[:zip]
post[:C_country] = billing_address[:country]
post[:C_telephone] = billing_address[:phone]
Expand Down
36 changes: 35 additions & 1 deletion test/unit/gateways/sage_bankcard_test.rb
Expand Up @@ -138,7 +138,41 @@ def test_cvv_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'M', response.cvv_result['code']
end


def test_us_address_with_state
post = {}
options = {
:billing_address => { :country => "US", :state => "CA"}
}
@gateway.send(:add_addresses, post, options)

assert_equal "US", post[:C_country]
assert_equal "CA", post[:C_state]
end

def test_us_address_without_state
post = {}
options = {
:billing_address => { :country => "US", :state => ""}
}
@gateway.send(:add_addresses, post, options)

assert_equal "US", post[:C_country]
assert_equal "", post[:C_state]
end


def test_international_address_without_state
post = {}
options = {
:billing_address => { :country => "JP", :state => ""}
}
@gateway.send(:add_addresses, post, options)

assert_equal "JP", post[:C_country]
assert_equal "Outside of United States", post[:C_state]
end

private
def successful_authorization_response
"\002A911911APPROVED 00MX001234567890\0341000\0340\034\003"
Expand Down

0 comments on commit 39e6eb0

Please sign in to comment.