Skip to content

Commit

Permalink
Adding the ability to run a card store when performing an authorize()…
Browse files Browse the repository at this point in the history
…. Returns an array with the response for authorize and store
  • Loading branch information
robbyrussell committed Dec 1, 2008
1 parent 2f71bf9 commit dc92ea5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/active_merchant/billing/gateways/merchant_e_solutions.rb
Expand Up @@ -28,7 +28,17 @@ def authorize(money, creditcard_or_card_id, options = {})
add_invoice(post, options)
add_payment_source(post, creditcard_or_card_id, options)
add_address(post, options)
commit('P', money, post)
authorize_result = commit('P', money, post)

unless options.has_key? :store
options[:store] = false
end

if options[:store]
return [authorize_result, store(creditcard_or_card_id, options)]
else
return authorize_result
end
end

# returns a single ActiveMerchant::Billing::Response object unless options[:store] == true
Expand Down
11 changes: 11 additions & 0 deletions test/unit/gateways/merchant_e_solutions_test.rb
Expand Up @@ -48,6 +48,12 @@ def test_authorization
assert_equal '42e52603e4c83a55890fbbcfb92b8de1', response.authorization
assert response.test?
end

def test_authorization_with_store
@gateway.expects(:authorize).returns(successful_authorization_with_store_response)
assert response = @gateway.authorize(@amount, @credit_card, @options.merge({:store => true}))
assert_instance_of Array, response
end

def test_capture
@gateway.expects(:ssl_post).returns(successful_capture_response)
Expand Down Expand Up @@ -152,6 +158,11 @@ def successful_purchase_store_response
def successful_authorization_response
'transaction_id=42e52603e4c83a55890fbbcfb92b8de1&error_code=000&auth_response_text=Exact Match&auth_code=12345A'
end

def successful_authorization_with_store_response
[ 'transaction_id=42e52603e4c83a55890fbbcfb92b8de1&error_code=000&auth_response_text=Exact Match&auth_code=12345A',
'transaction_id=ae641b57b19b3bb89faab44191479872&error_code=000&auth_response_text=Card Data Stored']
end

def successful_credit_response
'transaction_id=0a5ca4662ac034a59595acb61e8da025&error_code=000&auth_response_text=Credit Approved'
Expand Down

0 comments on commit dc92ea5

Please sign in to comment.