Skip to content

Commit

Permalink
Add solution id to the AIM transaction objects
Browse files Browse the repository at this point in the history
Solution id provides the functionality to review transactions on the basis
of single id for a partner devloper. So adding an option to provide the
solution_id when the transaction is created in old model for AIM
transactions. Also adding a test case to check the solution_id is set
properly from the response returned from the server.

Signed-off-by: Srijan Misra <[email protected]>
  • Loading branch information
Srijan Misra authored and Srijan Misra committed Oct 27, 2015
1 parent 01a4b8f commit 69ee4fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/authorize_net/aim/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def initialize(api_login_id, api_transaction_key, options = {})
@verify_ssl = options[:verify_ssl]
@market_type = options[:market_type]
@device_type = options[:device_type]
@solution_id = options[:solution_id]
end

# Checks if the transaction has been configured for test mode or not. Return TRUE if the
Expand Down Expand Up @@ -127,6 +128,10 @@ def run
def cp_version
@cp_version
end

def solution_id
@solution_id
end

#:enddoc:
protected
Expand All @@ -147,6 +152,7 @@ def make_request
fields[:test_request] = boolean_to_value(@test_mode)
fields[:allow_partial_auth] = 'TRUE' if @allow_split_transaction
fields[:encap_char] = @encapsulation_character unless @encapsulation_character.nil?
fields[:solution_id] = @solution_id unless @solution_id.nil?
fields.each do |k, v|
if @@boolean_fields.include?(k)
fields[k] = boolean_to_value(v)
Expand Down
1 change: 1 addition & 0 deletions lib/authorize_net/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Fields
:md5_hash,
:card_code_response,
:cardholder_authentication_verification_response,
:solution_id,
nil,
nil,
nil,
Expand Down
9 changes: 9 additions & 0 deletions spec/aim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@api_key = creds['api_transaction_key']
@api_login = creds['api_login_id']
@md5_value = creds['md5_value']
@solution_id = "AAA100302"
rescue Errno::ENOENT => e
@api_key = "TEST"
@api_login = "TEST"
Expand Down Expand Up @@ -184,6 +185,14 @@
transaction.purchase(@amount, @credit_card).should be_kind_of(AuthorizeNet::AIM::Response)
transaction.response.success?.should be_truthy
end

it "should support setting solution id" do
transaction = AuthorizeNet::AIM::Transaction.new(@api_login, @api_key, :transaction_type => @type, :gateway => @gateway, :test => @test_mode, :solution_id => @solution_id)
transaction.purchase(@amount, @credit_card).should be_kind_of(AuthorizeNet::AIM::Response)
transaction.response.success?.should be_truthy
fields = transaction.response.transaction
(defined?(fields.solution_id) and fields.solution_id == 'AAA100302').should be_truthy
end

it "should support adding an email receipt" do
transaction = AuthorizeNet::AIM::Transaction.new(@api_login, @api_key, :transaction_type => @type, :gateway => @gateway, :test => @test_mode)
Expand Down

0 comments on commit 69ee4fc

Please sign in to comment.