diff --git a/lib/active_merchant/billing/gateways/sallie_mae.rb b/lib/active_merchant/billing/gateways/sallie_mae.rb index 61906c88350..6ade8bd48d7 100644 --- a/lib/active_merchant/billing/gateways/sallie_mae.rb +++ b/lib/active_merchant/billing/gateways/sallie_mae.rb @@ -78,7 +78,8 @@ def add_address(post, creditcard, options) end def add_invoice(post, options) - post[:ci_memo] = options[:description].to_s unless options[:description].blank? + memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}" + post[:ci_memo] = memo end def add_creditcard(post, creditcard) @@ -104,21 +105,19 @@ def parse(body) def commit(action, money, parameters) parameters[:acctid] = @options[:account_id].to_s parameters[:subid] = @options[:sub_id].to_s if @options[:sub_id].blank? + parameters[:amount] = "%.2f" % (money / 100.0) case action when :sale parameters[:action] = "ns_quicksale_cc" - parameters[:amount] = "%.2f" % (money / 100.0) when :authonly parameters[:action] = "ns_quicksale_cc" parameters[:authonly] = 1 - parameters[:amount] = "%.2f" % (money / 100.0) when :capture parameters[:action] = "ns_quicksale_cc" - parameters[:amount] = "%.2f" % (money / 100.0) end - response = parse(ssl_post(URL, parameters.to_post_data)) + response = parse(ssl_post(URL, parameters.to_post_data) || "") Response.new(successful?(response), message_from(response), {}, :authorization => response["refcode"]) end diff --git a/test/unit/gateways/sallie_mae_test.rb b/test/unit/gateways/sallie_mae_test.rb index 8f51ea8d76c..b884a62554d 100644 --- a/test/unit/gateways/sallie_mae_test.rb +++ b/test/unit/gateways/sallie_mae_test.rb @@ -3,8 +3,7 @@ class SallieMaeTest < Test::Unit::TestCase def setup @gateway = SallieMaeGateway.new( - :login => 'login', - :password => 'password' + :account_id => 'FAKEACCOUNT' ) @credit_card = credit_card @@ -21,29 +20,25 @@ def test_successful_purchase @gateway.expects(:ssl_post).returns(successful_purchase_response) assert response = @gateway.purchase(@amount, @credit_card, @options) - assert_instance_of assert_success response - - # Replace with authorization number from the successful response - assert_equal '', response.authorization - assert response.test? end def test_unsuccessful_request - @gateway.expects(:ssl_post).returns(failed_purchase_response) + @gateway.expects(:ssl_post).returns(failed_purcahse_response) assert response = @gateway.purchase(@amount, @credit_card, @options) assert_failure response - assert response.test? end private # Place raw successful response from gateway here def successful_purchase_response + "Status=Accepted" end # Place raw failed response from gateway here def failed_purcahse_response + "Status=Declined" end end