Skip to content

Commit

Permalink
+ merged changes from AuthorizeNet#31
Browse files Browse the repository at this point in the history
  • Loading branch information
namanbansal committed Nov 19, 2015
1 parent 7ff8ac5 commit 8eb6b39
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/authorize_net/xml_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ def initialize(api_login_id, api_transaction_key, options = {})
options = @@option_defaults.merge(options)
@verify_ssl = options[:verify_ssl]
@reference_id = options[:reference_id]
case options[:gateway]
when :sandbox, :test
@gateway = Gateway::TEST
when :production, :live
@gateway = Gateway::LIVE
@gateway = case options[:gateway].to_s
when 'sandbox', 'test'
Gateway::TEST
when 'production', 'live'
Gateway::LIVE
else
@gateway = options[:gateway]
options[:gateway]
end
end

Expand Down
9 changes: 9 additions & 0 deletions spec/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
expect(response.messages).not_to eq(nil)
expect(response.messages.resultCode).not_to eq(nil)
expect(response.messages.resultCode).to eq(MessageTypeEnum::Ok)

transaction = Transaction.new(@api_login, @api_key, :gateway => 'sandbox')
response = transaction.authenticate_test_request(@testRequest)

expect(response).not_to eq(nil)
expect(response.messages).not_to eq(nil)
expect(response.messages.resultCode).not_to eq(nil)
expect(response.messages.resultCode).to eq(MessageTypeEnum::Ok)

end

it "should be able to run credit card transaction" do
Expand Down
4 changes: 4 additions & 0 deletions spec/arb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@
it "should know if its running against the sandbox or not" do
transaction = AuthorizeNet::ARB::Transaction.new(@api_login, @api_key, :gateway => :sandbox)
transaction.test?.should be_truthy
transaction = AuthorizeNet::ARB::Transaction.new(@api_login, @api_key, :gateway => 'sandbox')
transaction.test?.should be_truthy
transaction = AuthorizeNet::ARB::Transaction.new(@api_login, @api_key, :gateway => :live)
transaction.test?.should be_falsey
transaction = AuthorizeNet::ARB::Transaction.new(@api_login, @api_key, :gateway => 'live')
transaction.test?.should be_falsey
transaction = AuthorizeNet::ARB::Transaction.new(@api_login, @api_key, :gateway => 'moose')
transaction.test?.should be_truthy
end
Expand Down
4 changes: 4 additions & 0 deletions spec/cim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ def delete_profile(profile)
it "should know if its running against the sandbox or not" do
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => :sandbox)
expect(transaction.test?).to eq true
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => 'sandbox')
expect(transaction.test?).to eq true
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => :live)
expect(transaction.test?).to eq false
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => 'live')
expect(transaction.test?).to eq false
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => 'moose')
expect(transaction.test?).to eq true
end
Expand Down

0 comments on commit 8eb6b39

Please sign in to comment.