Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
USA ePay Advanced: Fix check handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nearapogee authored and ntalbott committed Dec 11, 2013
1 parent 4abb70c commit 90488d5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Braintree Blue: Return :credit_card_token as a top level param [ntalbott]
* Braintree Blue: Allow unstoring just a credit card [ntalbott]
* Braintree Blue: #store adds cards to existing customers [ntalbott]
* USA ePay Advanced: Fix check handling [nearapogee]

== Version 1.42.2 (November 13th, 2013)

Expand Down
8 changes: 5 additions & 3 deletions lib/active_merchant/billing/gateways/usa_epay_advanced.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class UsaEpayAdvancedGateway < Gateway
} #:nodoc:

CHECK_DATA_OPTIONS = {
:check_number => [:integer, 'CheckNumber'],
:drivers_license => [:string, 'DriversLicense'],
:drivers_license_state => [:string, 'DriversLicenseState'],
:record_type => [:string, 'RecordType'],
Expand Down Expand Up @@ -1251,9 +1250,11 @@ def build_credit_card_or_check(soap, payment_method)
end
build_tag soap, :string, 'CardCode', payment_method[:method].verification_value
when payment_method[:method].kind_of?(ActiveMerchant::Billing::Check)
build_tag soap, :string, 'Account', payment_method[:method].number
build_tag soap, :string, 'Account', payment_method[:method].account_number
build_tag soap, :string, 'Routing', payment_method[:method].routing_number
build_tag soap, :string, 'AccountType', payment_method[:method].account_type.capitalize
unless payment_method[:method].account_type.nil?
build_tag soap, :string, 'AccountType', payment_method[:method].account_type.capitalize
end
build_tag soap, :string, 'DriversLicense', options[:drivers_license]
build_tag soap, :string, 'DriversLicenseState', options[:drivers_license_state]
build_tag soap, :string, 'RecordType', options[:record_type]
Expand Down Expand Up @@ -1339,6 +1340,7 @@ def build_credit_card_data(soap, options)

def build_check_data(soap, options)
soap.CheckData 'xsi:type' => "ns1:CheckData" do |soap|
build_tag soap, :integer, 'CheckNumber', options[:payment_method].number
build_tag soap, :string, 'Account', options[:payment_method].account_number
build_tag soap, :string, 'Routing', options[:payment_method].routing_number
build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize
Expand Down
60 changes: 32 additions & 28 deletions test/remote/gateways/remote_usa_epay_advanced_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@
require 'logger'

class RemoteUsaEpayAdvancedTest < Test::Unit::TestCase

def setup
# Optional Logger Setup
# UsaEpayAdvancedGateway.logger = Logger.new('/tmp/usa_epay.log')
# UsaEpayAdvancedGateway.logger.level = Logger::DEBUG

# Optional Wiredump Setup
# UsaEpayAdvancedGateway.wiredump_device = File.open('/tmp/usa_epay_dump.log', 'a+')
# UsaEpayAdvancedGateway.wiredump_device.sync = true

@gateway = UsaEpayAdvancedGateway.new(fixtures(:usa_epay_advanced))

@amount = 2111

@credit_card = ActiveMerchant::Billing::CreditCard.new(
:number => '4000100011112224',
:month => 12,
Expand All @@ -37,19 +28,19 @@ def setup
)

@check = ActiveMerchant::Billing::Check.new(
:number => '123456789',
:account_number => '123456789',
:routing_number => '120450780',
:account_type => 'checking',
:first_name => "Fred",
:last_name => "Flintstone"
)

cc_method = [
{:name => "My CC", :sort => 5, :method => @credit_card},
{:name => "My CC", :sort => 5, :method => @credit_card},
{:name => "Other CC", :sort => 12, :method => @credit_card}
]

@options = {
@options = {
:client_ip => '127.0.0.1',
:billing_address => address,
}
Expand Down Expand Up @@ -86,6 +77,12 @@ def setup
:amount => 10000
}

@run_transaction_check_options = {
:payment_method => @check,
:command => 'check',
:amount => 10000
}

@run_sale_options = {
:payment_method => @credit_card,
:amount => 5000
Expand All @@ -97,20 +94,20 @@ def setup
}

payment_methods = [
{
{
:name => "My Visa", # optional
:sort => 2, # optional
:method => @credit_card
},
{
{
:name => "My Checking",
:method => @check
}
]
end

# Standard Gateway ==================================================

def test_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'A', response.params['run_sale_return']['result_code']
Expand All @@ -130,7 +127,7 @@ def test_capture

def test_void
assert purchase = @gateway.purchase(@amount, @credit_card, @options.dup)

assert credit = @gateway.void(purchase.authorization, @options)
assert_equal 'true', credit.params['void_transaction_return']
end
Expand Down Expand Up @@ -161,7 +158,7 @@ def test_invalid_login
assert_failure response
assert_equal 'Invalid software ID', response.message
end

# Customer ==========================================================

def test_add_customer
Expand All @@ -172,7 +169,7 @@ def test_add_customer
def test_update_customer
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

@options.merge!(@update_customer_options.merge!(:customer_number => customer_number))
response = @gateway.update_customer(@options)
assert response.params['update_customer_return']
Expand All @@ -192,7 +189,7 @@ def test_enable_disable_customer
def test_add_customer_payment_method
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

@options.merge!(:customer_number => customer_number).merge!(@add_payment_options)
response = @gateway.add_customer_payment_method(@options)
assert response.params['add_customer_payment_method_return']
Expand All @@ -201,7 +198,7 @@ def test_add_customer_payment_method
def test_add_customer_payment_method_verify
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

@add_payment_options[:payment_method][:method] = @bad_credit_card
@options.merge!(:customer_number => customer_number, :verify => true).merge!(@add_payment_options)
response = @gateway.add_customer_payment_method(@options)
Expand All @@ -211,7 +208,7 @@ def test_add_customer_payment_method_verify
def test_get_customer_payment_methods
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

response = @gateway.get_customer_payment_methods(:customer_number => customer_number)
assert response.params['get_customer_payment_methods_return']['item']
end
Expand All @@ -230,12 +227,12 @@ def test_get_customer_payment_method
def test_update_customer_payment_method
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

@options.merge!(:customer_number => customer_number).merge!(@add_payment_options)
response = @gateway.add_customer_payment_method(@options)
payment_method_id = response.params['add_customer_payment_method_return']

update_payment_options = @add_payment_options[:payment_method].merge(:method_id => payment_method_id,
update_payment_options = @add_payment_options[:payment_method].merge(:method_id => payment_method_id,
:name => "Updated Card.")
response = @gateway.update_customer_payment_method(update_payment_options)
assert response.params['update_customer_payment_method_return']
Expand All @@ -244,7 +241,7 @@ def test_update_customer_payment_method
def test_delete_customer_payment_method
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

@options.merge!(:customer_number => customer_number).merge!(@add_payment_options)
response = @gateway.add_customer_payment_method(@options)
id = response.params['add_customer_payment_method_return']
Expand All @@ -256,7 +253,7 @@ def test_delete_customer_payment_method
def test_delete_customer
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']

response = @gateway.delete_customer(:customer_number => customer_number)
assert response.params['delete_customer_return']
end
Expand All @@ -278,6 +275,13 @@ def test_run_transaction
assert response.params['run_transaction_return']
end

def test_run_transaction_check
@options.merge!(@run_transaction_check_options)
response = @gateway.run_transaction(@options)
assert response.params['run_transaction_return']
assert response.success?
end

def test_run_sale
@options.merge!(@run_sale_options)
response = @gateway.run_sale(@options)
Expand Down Expand Up @@ -413,7 +417,7 @@ def test_get_transaction_custom
response = @gateway.run_sale(@options.merge(@run_sale_options))
reference_number = response.params['run_sale_return']['ref_num']

response = @gateway.get_transaction_custom(:reference_number => reference_number,
response = @gateway.get_transaction_custom(:reference_number => reference_number,
:fields => ['Response.StatusCode', 'Response.Status'])
assert response.params['get_transaction_custom_return']
end
Expand Down

0 comments on commit 90488d5

Please sign in to comment.