Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add Gateway for Moneris US #313

Merged
merged 1 commit into from Mar 23, 2012

Conversation

Projects
None yet
2 participants
Contributor

eddanger commented Mar 21, 2012

No description provided.

Contributor

ntalbott commented Mar 21, 2012

Is Moneris US a completely different gateway than the other Moneris gateway we already support?

Contributor

eddanger commented Mar 21, 2012

Yes, it is a completely different gateway.

Contributor

ntalbott commented Mar 22, 2012

I'm getting errors when running the unit tests:

  1) Error:
test_capture_is_valid_xml(MonerisUsTest):
NoMethodError: undefined method `each' for nil:NilClass
    /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/moneris_us.rb:172:in `post_data'
    ./test/unit/gateways/moneris_us_test.rb:94:in `send'
    ./test/unit/gateways/moneris_us_test.rb:94:in `test_capture_is_valid_xml'
    /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
    /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run'

  2) Error:
test_purchase_is_valid_xml(MonerisUsTest):
NoMethodError: undefined method `each' for nil:NilClass
    /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/moneris_us.rb:172:in `post_data'
    ./test/unit/gateways/moneris_us_test.rb:79:in `send'
    ./test/unit/gateways/moneris_us_test.rb:79:in `test_purchase_is_valid_xml'
    /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
    /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run'

I'm also getting a failure when running remote tests:

  1) Failure:
test_successful_authorization_and_void(MonerisUsRemoteTest)
    [test/remote/gateways/remote_moneris_us_test.rb:50:in `test_successful_authorization_and_void'
     /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
     /Users/ntalbott/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run']:
Response failed: #<ActiveMerchant::Billing::Response:0x10a6f5440 @authorization=nil, @success=nil, @cvv_result={"code"=>nil, "message"=>nil}, @params={"trans_id"=>nil, "ticket"=>nil, "card_type"=>nil, "response_code"=>nil, "timed_out"=>nil, "iso"=>nil, "trans_time"=>nil, "receipt_id"=>nil, "trans_date"=>nil, "complete"=>false, "trans_amount"=>nil, "trans_type"=>nil, "auth_code"=>nil, "reference_num"=>nil, "bank_totals"=>nil, "message"=>"Invalid follow_up_amount number"}, @fraud_review=nil, @message="Invalid follow_up_amount number", @avs_result={"code"=>nil, "postal_match"=>nil, "street_match"=>nil, "message"=>nil}, @test=true>.
<nil> is not true.

The code looks solid, so if you can get me fixes for the tests, I'll be happy to merge. Thanks!

Contributor

eddanger commented Mar 22, 2012

Hi @ntalbott I've fixed up the Unit and Remote tests.

I also fixed a failing test for the Moneris Canada gateway. Recent changes to Moneris no longer allow a void on a preauthorization. You must capture a $0.00 on the auth to in effect void it.

The Moneris Canada remote test fix is also in this pull request if that is okay.

Contributor

ntalbott commented Mar 22, 2012

Actually would be best to split the void change into another PR; I think we'll actually want to abstract away the zero-dollar capture behind the void method.

Contributor

eddanger commented Mar 22, 2012

One issue is the void method behaves differently depending on whether the original transaction was an auth or purchase/capture. And we only know the authorization of the transaction, not the type. One solution may be to create a void_authorization method that does the capture of $0.00.

Also, is it possible to remove/change a commit from a pull request?

Contributor

eddanger commented Mar 22, 2012

Another possibility is to remove that test altogether since only captures and purchases can be voided.

Contributor

ntalbott commented Mar 22, 2012

The PR is based on the branch, so if you force push a different set of commits into the branch, the PR will update.

If the type of the transaction matters, maybe we should add additional info to the authorization string to indicate that?

Contributor

eddanger commented Mar 22, 2012

Done, void the authorization commit removed. I'll make a new pull request for these changes.

Contributor

ntalbott commented Mar 22, 2012

Still getting a remote failure:

  1) Failure:
test_successful_authorization_and_void(MonerisUsRemoteTest)
    [test/remote/gateways/remote_moneris_us_test.rb:50:in `test_successful_authorization_and_void'
     /Users/ntalbott/.rbenv/versions/1.8.7-p358/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
     /Users/ntalbott/.rbenv/versions/1.8.7-p358/lib/ruby/gems/1.8/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run']:
Response failed: #<ActiveMerchant::Billing::Response:0x106929210 @fraud_review=nil, @avs_result={"street_match"=>nil, "message"=>nil, "postal_match"=>nil, "code"=>nil}, @test=true, @message="Invalid follow_up_amount number", @authorization=nil, @success=nil, @cvv_result={"message"=>nil, "code"=>nil}, @params={"message"=>"Invalid follow_up_amount number", "bank_totals"=>nil, "receipt_id"=>nil, "trans_type"=>nil, "trans_date"=>nil, "reference_num"=>nil, "trans_amount"=>nil, "response_code"=>nil, "timed_out"=>nil, "iso"=>nil, "auth_code"=>nil, "complete"=>false, "ticket"=>nil, "trans_time"=>nil, "card_type"=>nil, "trans_id"=>nil}>.
<nil> is not true.
Contributor

eddanger commented Mar 22, 2012

Fix added back in (curses that force push!)

Contributor

ntalbott commented Mar 23, 2012

Working beautifully, just one last request: can you squash this all into a single commit? I'll merge ASAP once I have that. Thanks!

Add Gateway for Moneris US
Fix unit tests for Moneris US XML

Moneris US cannot void a preauthorization
Bring this in line with the way Moneris Canada does things.
Contributor

eddanger commented Mar 23, 2012

Hi, @ntalbott squashed them into a single commit! Interesting. I have never done something like that before, and was just wondering what the benefit is?

Contributor

ntalbott commented Mar 23, 2012

With a large open source project with a lot of contributors, it's really handy to keep the history as clean as possible. Makes it much easier to see at a glance what's gone on and who has done what.

ntalbott added a commit that referenced this pull request Mar 23, 2012

@ntalbott ntalbott merged commit a63697a into activemerchant:master Mar 23, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment