From 90488d5710a3e17458fa95c5ba00dea9f3943249 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Thu, 23 Feb 2012 08:35:46 -0800 Subject: [PATCH] USA ePay Advanced: Fix check handling --- CHANGELOG | 1 + .../billing/gateways/usa_epay_advanced.rb | 8 ++- .../gateways/remote_usa_epay_advanced_test.rb | 60 ++++++++++--------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1788e8a3d1d..057683fd2f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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) diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb index ef4a076f070..6da7602f575 100644 --- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb @@ -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'], @@ -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] @@ -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 diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb index 1692e30dd4c..17af64106d4 100644 --- a/test/remote/gateways/remote_usa_epay_advanced_test.rb +++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb @@ -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, @@ -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, } @@ -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 @@ -97,12 +94,12 @@ def setup } payment_methods = [ - { + { :name => "My Visa", # optional :sort => 2, # optional :method => @credit_card }, - { + { :name => "My Checking", :method => @check } @@ -110,7 +107,7 @@ def setup end # Standard Gateway ================================================== - + def test_purchase assert response = @gateway.purchase(@amount, @credit_card, @options) assert_equal 'A', response.params['run_sale_return']['result_code'] @@ -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 @@ -161,7 +158,7 @@ def test_invalid_login assert_failure response assert_equal 'Invalid software ID', response.message end - + # Customer ========================================================== def test_add_customer @@ -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'] @@ -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'] @@ -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) @@ -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 @@ -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'] @@ -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'] @@ -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 @@ -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) @@ -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