test/unit/gateways/linkpoint_test.rb in activemerchant-1.4.2 vs test/unit/gateways/linkpoint_test.rb in activemerchant-1.5.0

- old
+ new

@@ -1,6 +1,6 @@ -require File.dirname(__FILE__) + '/../../test_helper' +require 'test_helper' class LinkpointTest < Test::Unit::TestCase def setup Base.mode = :test @@ -27,10 +27,19 @@ assert_instance_of Response, response assert_success response assert_equal '1000', response.authorization end + def test_successful_capture + @gateway.expects(:ssl_post).returns(successful_capture_response) + + assert response = @gateway.capture(@email, '1000', @options) + assert_instance_of Response, response + assert_success response + assert_equal '1000', response.authorization + end + def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_instance_of Response, response @@ -51,15 +60,15 @@ assert response = @gateway.recurring(2400, @credit_card, :order_id => 1003, :installments => 12, :startdate => "immediate", :periodicity => :monthly) assert_success response end def test_amount_style - assert_equal '10.34', @gateway.send(:amount, 1034) + assert_equal '10.34', @gateway.send(:amount, 1034) - assert_raise(ArgumentError) do - @gateway.send(:amount, '10.34') - end + assert_raise(ArgumentError) do + @gateway.send(:amount, '10.34') + end end def test_purchase_is_valid_xml parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1004, :billing_address => { @@ -67,15 +76,15 @@ :city => 'Lost Angeles', :state => 'CA', :zip => '90210' } ) - + assert data = @gateway.send(:post_data, @amount, @credit_card, @options) assert REXML::Document.new(data) end - + def test_recurring_is_valid_xml parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006, :billing_address => { :address1 => '1313 lucky lane', :city => 'Lost Angeles', @@ -85,10 +94,27 @@ ) assert data = @gateway.send(:post_data, @amount, @credit_card, @options) assert REXML::Document.new(data) end + def test_line_items_are_valid_xml + options = {:ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006, + :billing_address => { + :address1 => '1313 lucky lane', + :city => 'Lost Angeles', + :state => 'CA', + :zip => '90210' + }, + :line_items => [{:id => '123456', :description => "Logo T-Shirt", :price => + "12.00", :quantity => '1', :options => [{:name => "Color", :value => + "Red"}, {:name => "Size", :value => "XL"}]},{:id => '111', :description => "keychain", :price => "3.00", :quantity => '1'}]} + + + assert data = @gateway.send(:post_data, @amount, @credit_card, options) + assert REXML::Document.new(data) + end + def test_declined_purchase_is_valid_xml @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM') parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1005, :billing_address => { @@ -149,9 +175,13 @@ end private def successful_authorization_response '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:41:31 2008</r_time><r_ref>0004486182</r_ref><r_error/><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486182:NNNM:100018312899:</r_code><r_tdate>1199680890</r_tdate><r_score/><r_authresponse/><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>' + end + + def successful_capture_response + '<r_csp>CSI</r_csp><r_time>Wed Dec 2 13:57:19 2009</r_time><r_ref>0009554566</r_ref><r_error></r_error><r_ordernum>1000</r_ordernum><r_message>ACCEPTED</r_message><r_code>0000000009554566: :9554566:</r_code><r_tdate>1259780240</r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>APPROVED</r_approved><r_avs> </r_avs>' end def successful_purchase_response '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:45:22 2008</r_time><r_ref>0004486195</r_ref><r_error></r_error><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486195:NNNM:100018312912:</r_code><r_tdate>1199681121</r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>' end