Line 510 reads:

 if (($this_trans_type == uc_moneris_preauth_string() && $txn_type == uc_moneris_transaction_type()) && intval($response_code) < 49 || $completed == 'true') {

If the transaction type was "purchase" (or "us_purchase") then it is possible that $completed == 'true', which means that the above condition will *always* return true and attempt to run a capture. However, the funds will have already been captured if the type was "purchase" (or "us_purchase"), correct?

Shouldn't the condition read as the following?

 if ($this_trans_type == uc_moneris_preauth_string() && $txn_type == uc_moneris_transaction_type() && intval($response_code) <= 49 && $completed == 'true') {

According to the documentation, response codes are inclusive up to 49.

Also, I am unsure of the real difference between $this_trans_type and $txn_type.

Comments

c4rl’s picture

I've been running this module with some updated API code from Moneris and I can say (at least in part) it appears to be working well this change (at least for US Purchase). Patch and files for review coming soon.

c4rl’s picture

Status: Active » Needs review
StatusFileSize
new4.93 KB
new4.7 KB
new2.79 KB

The attached patch is working for me. I've made the modification to the line mentioned above, and done some switching based on whether the store is US or Canadian.

I've also included the updated mpgClasses.php files from Moneris. There are two different versions. I've put these in directories called api_us and api_can. These are attached, and should be extracted and put in the uc_moneris directory. A bit messy.

There's some question whether these should be distributed with the module since they are not explicitly GPL.

c4rl’s picture

StatusFileSize
new7.27 KB

The previous patch was causing my shell to hang -- probably because I didn't create it with "cvs diff." Here's one that seems to work. Don't forget to extract the compressed directories from the previous comment #2.

ailgm’s picture

I've tried your patch, to see if it would happen to solve the issue I'm encountering (http://drupal.org/node/723604).

(It didn't.) An additional log entry was generated, with a message of:
CardType = null
TransAmount = null
TxnNumber = null
ReceiptId = null
TransType = null
ReferenceNum = null
ResponseCode = null
Message = Cancelled: Data format problem
AuthCode = null
Complete = false
TransDate = null
TransTime = null
Ticket = null
TimedOut = null

c4rl’s picture

Yes, I added that watchdog message in to help me debug -- maybe it would be better if it were removed, but I think it's helpful for now.

What worked for me are the following parameters:

Card: 4242424242424242
Exp: (sometime in the future) 11/11
CVV: 123
Amount: $10.00

Store ID: monusqa002
API Token: qatoken

You should be able to see successful transactions here:
URL (QA): https://esplusqa.moneris.com/usmpg/index.php

greggles’s picture

There's another issue in the queue about a debug feature #716066: provide guidance and a log feature to debug the gateway which I think makes great sense ;)

mmuzard’s picture

Hi, I was having the error found here : http://drupal.org/node/716062 where I would get "Payment failed for order 15: Credit card **purchase** declined: No Pre-auth corresponds to the store Id and order Id and transaction Id entered " even if the transaction was approved and processed by Moneris.

Now after applying the patch above and including the new api folders, I no longer get THAT error but instead the payment just hangs up - there is just a blank page.

I'm using the Canadian API btw. Has anybody had this issue? gotten around it? Thanks

mmuzard’s picture

sorry I forgot to include the error:

Cannot modify header information - headers already sent by (output started at .../sites/all/modules/uc_moneris/api_can/mpgClasses.php:795) in .../includes/common.inc on line 335.

other than that, the transaction was approved on both the Moneris end and the website

mmuzard’s picture

Nevermind:
I removed the last ?> tag from mpgClasses.php in the api_can folder and it works

mparkes’s picture

This patch works fine with the Canadian API providing you remove the ?> from the updated mpgClasses.php

Thank you so much! I have been struggling with this for a while now.

greggles’s picture

Here's a reroll of the patch.

I removed the debugging since it had no way to be disabled, in it's current form it's not translatable and could potentially be used for XSS (though that would be a really hard to achieve XSS).

I also rolled this with "-w" so it doesn't show any whitespace changes to make it easier to review, but I agree the whitespace does need to get cleaned up and have included those changes locally.

I also merged in the change from #716062: Possible problem with process response. since it affects the same line of code.

I hope to commit this today and would love a review.

greggles’s picture

Slightly updated version with better docs about how to switch gateways.

ezra-g’s picture

Status: Needs review » Needs work

There's an option in the UI to switch between the US an Canadian gateways - We should either remove that or tie it to this variable.
Reviewing shortly.

sreynen’s picture

Status: Needs work » Reviewed & tested by the community

The patch in #12 and the patch in #716062: Possible problem with process response. are slightly different, and I'm not really clear on why they're different or what the differences are changing, but they both solved the problem in my testing. Hopefully that's enough for RTBC.

pribeh’s picture

Applying the patch in #12 does not help with my problems although they may be unrelated. I'm experiencing the same issue as described here: http://drupal.org/node/741040

webadpro’s picture

Just curious if these patches have been ported to the alpha download on the project's page?