Help! When I applied the patch in #3025418: MD5 being phased out 1/31/2019 in favor of SHA-256 and tested, everything seemed to work fine. But now, we're getting the following error after some (but not all, although I have reproduced it every time I have tried it this morning) transactions:

An unauthenticated response from user after redirection from Authorize.Net made it to checkout! Calculated redirect hash: [some string] Received redirect hash: [completely different string] Order ID: 20520

On the user side, they get the message "We're sorry, but due to a technical problem, your order could not be processed. Please try placing the order again later." and the order stays in the Checkout: Payment state.

I generated a new signature key and re-pasted it into the rule in case I had messed something up before, but the error persists. Is there a step I have missed? Any troubleshooting help you can provide is greatly appreciated!

Comments

BrightBold created an issue. See original summary.

jerry’s picture

Assigned: Unassigned » jerry

I note that the error message being logged indicates that the problem is with the redirect hash, not the MD5/SHA-512 hash. These are unrelated, and there were no changes to the redirect hash logic. Did you change the value of your "Redirect validation key"? It's normally a 16-byte randomly-generated string.

brightbold’s picture

Assigned: jerry » Unassigned

Ah, sorry. I thought that was the MD5 hash because in the Rules interface that field is described as "An MD5 hash key for validating redirect responses. A random key has been generated for your convenience. Do not leave this blank!" So that's why I thought it was related, because it's also MD5.

But thanks for helping. I did not alter the value in that field. Is there a place in the AuthNet settings where I should be looking to confirm the values match? I don't see one.

brightbold’s picture

Sorry for changing metadata again. I already had this window open and it must have had "unassigned" selected from before you had assigned it to yourself. I'm so embarrassed that this is the second of your issues where this has happened to me today. Despite appearances, I really do know how to use the issue queue. But I guess I need to stop posting comments in already open windows. Aargh.

jerry’s picture

The redirect hash isn't part of the SIM/DPM API and has no settings on the Authorize side. There's a browser redirection involved in the completion of a SIM/DPM transaction, and the redirect hash is used by the module to try to prevent forged redirect messages. The module sends the hashed data to Authorize, and Authorize just sends it back. The module then checks to make sure the returned hash is correct before completing the transaction. This has no connection to the MD5/SHA-512 hash used earlier in the transaction.

Your error message shows no hash values at all, which seems problematic. I recommend that you replace whatever you currently have in the "Redirect validation key" setting with a new random 16-byte printable ASCII value, and see if that makes a difference.

brightbold’s picture

Issue summary: View changes

Thanks for the explanation; it's good to understand what's happening behind the scenes.

I removed the hash values from the error message because I wasn't sure whether posting them was a security risk, as the error is from the production site. I had placeholders to show I'd removed them but d.o stripped them and I didn't notice. So there are actually hash values in the error.

I just changed the redirect validation key to a new 16-digit combination of upper- and lower-case letters, numbers, and common symbols. I cleared the cache and re-attempted a purchase but still got the same error. Based on the comment "The MD5 I set was too complicated and special characters caused it to bork." in #1469744: Failure message displayed after checkout attempt: authorize.net processes while ubercart remains in checkout from your old Ubercart version of this module, I tried again with a key that contained no special characters (even though I had already attempted to make sure they weren't too special, but the hashes still aren't matching.

I appreciate your help on this.

jerry’s picture

Any other messages from the module being logged besides the one about the redirect hash mismatch?

brightbold’s picture

Nothing particularly informative. These are the four Watchdog entries (in reverse order, as they appear in the log):

  • 02/02/2019 - 1:47pm An unauthenticated response from user after redirection from Authorize.Net made it to checkout! Calculated redirect hash: [32-byte hash] Received redirect hash: [different 32-byte hash] Order ID: 20529
  • 02/02/2019 - 1:47pm Receiving redirect response for order 20529 from Authorize.Net
  • 02/02/2019 - 1:47pm An unauthenticated response from Authorize.Net made it to checkout.
  • 02/02/2019 - 1:47pm Receiving payment response for order 20529 from Authorize.Net
jerry’s picture

Actually, that is useful. This message:

02/02/2019 - 1:47pm An unauthenticated response from Authorize.Net made it to checkout.

is the key. It means that the first failure wasn't the redirect hash match, but the SHA-512 hash match. The redirect hash failure is incidental to the previous SHA one.

There's likely a mismatch between your Signature Key setting in the module configuration and the one generated and stored by Authorize.Net. Take a close look at the two. Is there an embedded line break in the module's pasted-in version? White space at the beginning and end *should* be ignored, but it's worth checking. Anything characters get truncated?

brightbold’s picture

I don't believe there's any way to see the key in AuthNet once it's been generated, so I generated a new one, copied it using Authorize.Net's "Copy to Clipboard" button, pasted it into Rules, tested and got the same result. So then I generated a new key, but since Authorize.Net adds a blank line at the beginning of the hash (which your module strips out), this time I just selected the characters and pasted those. I then recopied both into a file comparison program to confirm they match. However, I get the same result.

Here's some history in case there's a detail here that might be helpful:

I had originally entered the signature key on 1/29 using the second method where I stripped the white space. We had 6 out of 6 successful transactions over the next 36 hours, then yesterday morning we got our first two failures with this error, followed by two successful transactions.

My client reported the error today, and early in the troubleshooting I regenerated the signature key and copy-pasted it using the button (so whitespace was copied, then stripped by the module). That second key was in use for most of the 16 consecutive failures I've seen today — the first one or two were probably with the original key, before I changed it trying to troubleshoot. And the last two were with the two new keys described in the first paragraph. Of the 16 failures today, 15 were mine (although I have used several different email addresses and browsers), and one was from an actual customer.

Once again, I really appreciate your taking time to troubleshoot this on a weekend. It's very kind.

jerry’s picture

I'm having some difficulty understanding how a given Signature Key could work intermittently, with no changes to your module configuration, unless there's a problem on the Authorize side. I'm wondering if they might not be consistently returning the SHA hash for your account. Am I correct in understanding that all of the problems that you've observed have been with a single account?

Try adding the second two watchdog() invocations to the existing one around line 507 of commerce_authnet_simdpm.module:

  // Handle response, if valid.

  if (!$auth_successful || !$order) { // invalid response
    $message = t("We're sorry, but due to a technical problem, your order could not be processed. Please try placing the order again later.");
    watchdog('commerce_authnet_simdpm', 'An unauthenticated response from Authorize.Net made it to checkout. Order ID: !order_id',
             array("!order_id" => $order->order_id), WATCHDOG_ERROR);
    watchdog('commerce_authnet_simdpm', 'Returned security hash: !RHASH', array('!RHASH' => $auth_hash), WATCHDOG_DEBUG);
    watchdog('commerce_authnet_simdpm', 'Calculated security hash: !CHASH', array('!CHASH' => $local_hash), WATCHDOG_DEBUG);
  }

That will tell us if you're getting back a blank or missing hash from Authorize, or something silly like that.

brightbold’s picture

Here you go:

Calculated security hash: c4a7f4f686a866188bfcbe052849d6efe4cf36fd9151495b6e68fa77e6367525844293ddad8833f0a0da4c09bc17eb2c385a4dcb76304abc9e2b9eda191842bd

Returned security hash: 9BCCD54AAFDE4380BABD2F7260FAF491E82067195CB169B16883C336EF91591F110663B737F3A7C3F7DC068064D0D83AC6E7F3898DE4A014CA56FAB86BEBA338

The intermittent nature doesn't make any sense to me either. Could I have left the configuration tab open and accidentally changed something later in the week? Possibly, but I wouldn't then have accidentally changed it back to get the two successful transactions that followed. And today I intentionally changed both the signature key and the redirect validation hash, so if one of those had been unintentionally altered, that should be fixed now.

My only other thought is that since switching to SIM, we've intermittently had a problem with Commerce correctly redirecting when coming back from AuthNet. I originally reported that to you in #2929322: Redirect page not found error, but I think it's actually related to Commerce core per #2619834: Implement hook_commerce_checkout_access_alter() to deal with Payflow return errors. (And I really thought I'd commented to that effect on the issue I filed with this module. I must be the evil queen of typing up partial comments and not submitting them, sorry.) I don't really see how that could be related, since it generates a completely different error message that I'm not seeing now, but since it's another sporadic, not-consistently reproducible problem, I thought I'd mention it.

brightbold’s picture

Oh, and yes this is all a single account.

jerry’s picture

Do you have another account, including a sandbox account, that you could test with? No one else has reported this problem, either with this module or its Ubercart equivalent, and I haven't seen it in my own testing or among my own clients. If it's truly account-specific, you might need to get Authorize.Net involved to see if they might be bungling the hash calculation for some reason. If it's not, and there's some data-dependent edge case that triggers the problem, it ought to be possible to collect enough details about the values going into the hash to track it down.

On reflection, it's worth pointing out that the Signature Key is used *twice* in a transaction: first, in the payment request sent to Authorize, the time and a few other values (login ID, order ID, purchase amount) are hashed with the key on the Drupal side and that hash is recalculated as a check by Authorize; and second, Authorize hashes together a bunch of returned transaction information with the key and adds that to the payment response, whereupon Drupal recalculates the hash and compares the result. In your case, the first use is always working, or you'd be seeing a different error entirely. This means that your saved Signature Key is fine. The failure is coming from the second use of the key, and since we already know that the key is OK, there must be some variation in how Drupal and Authorize are hashing the data values together. One thing that occurs to me is that if the address/contact data contains characters that would be encoded by a check_plain(), you might see this kind of failure. I probably should be hashing together raw POST values. That could explain the intermittent nature of this. Is there anything in the contact data that you're testing with that might be encoded by check_plain()?

Since this is a production client, you might need to roll them back to the MD5 implementation in the short term. So long as you didn't remove the MD5 hash or transaction key on the Authorize end, you ought to be able to re-install V1.4 of this module. Both of those values are stored in the variables table in Drupal, and weren't removed by the new module (which just added the Signature Key), so the old version should still be able to access them. Authorize is going to break this at some point in the future by no longer returning the MD5 hash value, but it should be OK for a bit.

jerry’s picture

Here's a patch against the dev version of the module to test whether check_plain() in the hash calculation is the problem.

brightbold’s picture

Ooh, rolling back to unpatched* 1.4 worked beautifully. I thought somehow that generating the Signature Key was going to invalidate the previous configuration or I would have done that already. Fortunately I hadn't touched the MD5 hash or transaction key, and I still had those values saved in a dev copy of the site.

*well, it has the shipping address patch that was also included in the latest release. But it's had that patch for ages.

I do have a sandbox account. Let me see if I can get that connected and replicate the error with it (or not). Meanwhile I found all the transactions that had failed on production other than mine. I don't see any commonalities in the contact and address information of the ones that failed. check_plain() only affects quotation marks, ampersands, and angle brackets, right? One of the shipping recipients had an ampersand in the name, but that was the only one. (And I'm guessing you're only using the billing information anyway, not shipping.)

I'll post again when I've tested with your patch and with the sandbox account. I'm going to take a break and eat dinner now so it might be tomorrow or Monday now that the crisis of things not working on production is over — this is not how I planned to spend my Saturday! But I will definitely get back to you. Thank you so, so much for your help.

jerry’s picture

check_plain() only affects quotation marks, ampersands, and angle brackets, right?

So says the documentation. Both single and double quotes are included.

(And I'm guessing you're only using the billing information anyway, not shipping.)

Actually, Authorize specifies a long list of returned data to be hashed, including the shipping address:

        $hash_data =  "^" . $_POST['x_trans_id'] .
                      "^" . $_POST['x_test_request'] .
                      "^" . $_POST['x_response_code'] .
                      "^" . $_POST['x_auth_code'] .
                      "^" . $_POST['x_cvv2_resp_code'] .
                      "^" . $_POST['x_cavv_response'] .
                      "^" . $_POST['x_avs_code'] .
                      "^" . $_POST['x_method'] .
                      "^" . $_POST['x_account_number'] .
                      "^" . $_POST['x_amount'] .
                      "^" . $_POST['x_company'] .
                      "^" . $_POST['x_first_name'] .
                      "^" . $_POST['x_last_name'] .
                      "^" . $_POST['x_address'] .
                      "^" . $_POST['x_city'] .
                      "^" . $_POST['x_state'] .
                      "^" . $_POST['x_zip'] .
                      "^" . $_POST['x_country'] .
                      "^" . $_POST['x_phone'] .
                      "^" . $_POST['x_fax'] .
                      "^" . $_POST['x_email'] .
                      "^" . $_POST['x_ship_to_company'] .
                      "^" . $_POST['x_ship_to_first_name'] .
                      "^" . $_POST['x_ship_to_last_name'] .
                      "^" . $_POST['x_ship_to_address'] .
                      "^" . $_POST['x_ship_to_city'] .
                      "^" . $_POST['x_ship_to_state'] .
                      "^" . $_POST['x_ship_to_zip'] .
                      "^" . $_POST['x_ship_to_country'] .
                      "^" . $_POST['x_invoice_num'] .
                      "^";
brightbold’s picture

Update #1: I'm too stressed out to relax, so I'm still working on this. BEST. SATURDAY. NIGHT. EVER.

Update #2: Got the same error using the same account but with all the check_plain()s removed, so it wasn't that.

I'll update again when I've tested with the sandbox.

brightbold’s picture

OK, so in the sandbox it worked both in test mode with test transactions and live mode with test transactions. So now I guess I have to figure out what is different between the setups of the two accounts. One thing I noticed is that the sandbox was having me put in a CVV, whereas this field is not present on production. I wouldn't think that would make a difference, but we should at least be comparing apples to apples here. So I'll try to go through the two accounts side by side and see if I can find differences. If you have other thoughts on how else I should proceed, I'm delighted to hear them.

jerry’s picture

The CVV difference is interesting and seems worth pursuing. I haven't tested without it in the new version. The response hash includes much more data than it used to, including the CVV2 check response code. This shouldn't matter, as they're supposed to be generating their version of the hash based on the same response data that they're sending us, but accidents happen. If disabling it for the sandbox account breaks the comparison, that would be a good confirmation.

brightbold’s picture

Transactions are still successful after removing the CVV from the sandbox. I've gone through every setting in the AuthNet interface and ensured that the sandbox matches production. The only one that seemed different was the Payment Fields, but that didn't make any difference either.

So we have the one useful piece of data that I can't reproduce it with the sandbox, but nothing else useful that I can think of. Any thoughts on how the account could be responsible for the difference?

jerry’s picture

Status: Active » Postponed (maintainer needs more info)

Not really, I'm afraid. The problem does seem to be account-specific, and we have no insight into the account beyond their web interface.

At this point, I'd recommend reporting this to Authorize.Net support and asking them to review your account for any idiosyncrasies. You can tell them that the same software works with your sandbox account, and with other production accounts as well (as reported here by others). Please let us know what you find out. I'll postpone this for now.

I'm going to open a new issue regarding the use of check_plain() when calculating the response hash, and copy the patch in #15 there. It wasn't the cause of your problem (for most cases, anyway), but it still ought to be addressed.

brightbold’s picture

Status: Postponed (maintainer needs more info) » Active

Hmm. So immediately after I posted that, I thought that the one difference I hadn't tested was that I have been testing the sandbox in a development environment (albeit one cloned from production). So I tried updating the Rule on dev to use the production account instead of the sandbox and was able to successfully get a transaction through. Then I diffed the two branches, to make sure the code on both is the same, and it is.

So what is going on here??? Saturday I couldn't get a successful transaction no matter what I did, and today I can't get one to fail. I was starting to think that there was just something wrong with the account late last week that was causing it to throw errors, but if that was the case, it's a nice coincidence that the problems stopped when I reverted back to version 1.4. I'm completely stumped.

I suppose the next step is to merge my testing branch into master, pull the production database to the regular dev site, and test again.

Any other thoughts?

brightbold’s picture

Ah, we were posting at the same time. Sounds like contacting Authorize.net is a good next step. Maybe it was something temporary that happened to get resolved when I rolled back to the previous version. Coincidences *do* happen sometimes.

I'll let you know what, if anything, comes of that.

jerry’s picture

Status: Active » Postponed (maintainer needs more info)
brightbold’s picture

Status: Postponed (maintainer needs more info) » Active

Well, Authorize.net support was unhelpful. I got "I cannot see why your hash wasn't matching unfortunately," and "After reviewing your account, I'm not seeing any issues over the weekend and you were able to place orders with no issues." Because of course it looks good on their end — the transactions were being processed on their end, but failing on ours (which made customers super happy, to have their cards getting charged but not having their orders go through, ugh.) She ended with the more specific "There's nothing on our end that would have caused it, unless it [the signature key] was reset after you entered the key into the site."

I'm not sure if there were better, more specific questions I should have been asking (if you can think of any let me know and I will contact them again.)

I also tried to find out when the MD5 hash would be disabled as we're working on a Drupal 8 migration, so if they keep it in place long enough I don't need to worry about this on the Drupal 7 site. But they still can't be more specific than "a few months" which could be enough time or not, depending on how many "a few" is. Ugh.

So I'm not sure what else to do here other than to work hard on the Drupal 8 site and try to get it done before they disable the hash. Since I can't reproduce this now on dev, it seems possible that I could re-enable the new version on production and it would work, but I'm reluctant to find out the hard way that I'm wrong about that!

jerry’s picture

I'm not sure if there were better, more specific questions I should have been asking (if you can think of any let me know and I will contact them again.)

I don't think so. I was hoping that they might spot something unusual about your account upon review, but apparently not.

Since I can't reproduce this now on dev, it seems possible that I could re-enable the new version on production and it would work, but I'm reluctant to find out the hard way that I'm wrong about that!

It might be worth trying it using test mode after-hours, if only to take some of the pressure off of your D8 effort.

As I've still received no similar reports from other users of this module or its Ubercart counterpart, I'm going to assume that your earlier failures were somehow specific to either your Authorize account or your particular environment. I'm going to close this issue as "Can't duplicate", but please let us know if you find out more, and feel free to re-open it if you suspect that there's something here that I can fix. Sorry that we couldn't track it down so far.

jerry’s picture

Status: Active » Closed (cannot reproduce)
brightbold’s picture

Status: Closed (cannot reproduce) » Active

This seems like a reasonable solution on your part. Thanks for all your help on trying to track it down. I'll report back if I ever figure it out.

brightbold’s picture

Status: Active » Closed (cannot reproduce)

Aargh I've got to learn to check and make sure the old issue status isn't still in the selectbox if I'm posting in an open tab. Sorry, didn't mean to change it back.

jmuessig’s picture

I just wanted to add that we are experiencing a similar, intermittent issue where although the payment goes through fine at Authorize, it throws the error below (we don't get any info about hash values, though).

"An unauthenticated response from user after redirection from Authorize.Net made it to checkout!".

This is on a new Authorize account, with a new install of the 7.x-1.7 SIM/DPM module.

The order is then marked as abandoned. I'm not a developer, but I'm a pretty good monkey if you can give me some direction on how to help.

jmuessig’s picture

These are the errors we receive, in the order they appear in the logs. Note no mention of the hash values.

It seems to be somewhat random - we'll have an error, then have a different customer checkout with no problem later. We haven't been able to reproduce it on a live server with test transactions ourselves. It always seem to work for us.

We're using the SIM method. Would it make sense to switch to DPM to see if that helps things?

The "abandoned cart" transaction:

Tuesday, April 30, 2019 - 16:05 Receiving redirect response for order 2760 from Authorize.Net
Tuesday, April 30, 2019 - 16:05 An unauthenticated response from Authorize.Net made it to checkout. Cart order ID: 2760
Tuesday, April 30, 2019 - 16:05 Receiving payment response for order 2760 from Authorize.Net

And then later that day (with no changes to the settings), a successful transaction:

Tuesday, April 30, 2019 - 23:46 - Receiving redirect response for order 2765 from Authorize.Net
Tuesday, April 30, 2019 - 23:46 - Receiving payment response for order 2765 from Authorize.Net

jerry’s picture

Version: 7.x-1.6 » 7.x-1.7
Assigned: Unassigned » jerry
Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)

Re-opening the issue, as it may indeed be the same problem as originally reported.

This log entry:

Tuesday, April 30, 2019 - 16:05 An unauthenticated response from Authorize.Net made it to checkout. Cart order ID: 2760

indicates that the payment response posted by Authorize didn't pass the verification test, so the hash calculated and sent by Authorize didn't match the one we calculated ourselves. Since the payment request previously sent from your site to Authorize uses the same SHA key and was accepted (or the payment would have failed), the key itself should be fine. This again suggests that there are cases where Authorizes hashes some of the customer data (see #17 above) differently that we do *in some cases*. Have a look at those fields for the orders which failed and see if you can spot any unusual characters or punctuation which is common to them, but wouldn't appear in your test transactions or others which worked as expected.

Switching to DPM isn't likely to be helpful with this.

jmuessig’s picture

Sorry, my comments above were meant for the Ubercart version of this module, though I suspect this applies to both. Let me know if I should move the issue to there.

Your intuition was correct - I was able to reproduce a failure on a character used from one of the two customers. If you insert an "Ń" (i.e. with the accent mark) in the name field, it will trigger the issue. However, it left the cart in "in checkout" rather than abandoned, but all the error messages were the same.

Even though Authorize seems to recognize the "Ń" (it displays it on the SIM page), I'm guessing it's stripping it from the hash calculation or something? Pure speculation on my part.

I'm still working on the other customer's order. I'll let you know what I find.

Thanks so much for your help, support, and amazing response time! :) :) :)

jmuessig’s picture

Second customer with issue:

I'll do my best to explain this.

This transaction went through on Authorize's side, but showed up as "abandoned" on Ubercart.

The address looks completely normal on Ubercart's side. But for some reason in Authorize's Transaction Detail, it shows a "?" character right before the street name. In other words "1234 �YourStreet Rd." Again, there is nothing that shows up in that position on the Ubercart order page.

On the Merchant Email Receipt that Authorize sends, there is an extra space in place of that question mark character.

Later I will try adding an extra space to the address field and see if that also reproduces an error.

jmuessig’s picture

Okay, I verified that that adding two spaces in between the address number and the address street produces the "unauthenticated response" error, puts the cart in "in checkout", but the transaction completes on the Authorize side.

The "�" also appeared only in the transaction detail on Authorize.net, not in Ubercart or in the Merchant Receipt email.

The double space only appeared in the Merchant Receipt email. In ubercart, no indication of a double space exists.

Let me know if I can assist in any other way! :)

jerry’s picture

Status: Postponed (maintainer needs more info) » Active

Thanks for your testing on this.

I'm guessing that Authorize is doing some kind of text normalization on the raw data before generating their hash, but I don't recall seeing a description of it. I'll have another look at the available documentation over the weekend and make sure that I didn't miss something. If I don't find an explanation, I can try to recreate the problem against their dev server and then try a series of likely normalizations on the raw data before sending it to them in an attempt to deduce what they're up to.

I suppose it's also possible that they're not normalizing the data, but that their hash calculation handles the data differently from what we're doing in PHP for some unusual cases. If so, some kind of compatible pre-normalization on our end is likely still the required solution.

jmuessig’s picture

Thanks much, Jerry! I agree with your assessment, though I'm pretty ignorant on such matters.

There's a relevant discussion of it here: https://community.developer.authorize.net/t5/Integration-and-Testing/Rel...

jmuessig’s picture

More discussion of the "non-standard ASCII" character hash issue here. Question brought up on message 38, potential solution on message 43. It doesn't address Polish characters, though (which is what my customer was submitting), nor does it address the double space issue.

https://community.developer.authorize.net/t5/Integration-and-Testing/Upg...

jerry’s picture

Status: Active » Needs review
StatusFileSize
new4.04 KB

Thanks for doing all this legwork.

How Authorize is handling the character encoding during their hash calculation is a bit murky. I'm attaching a patch that converts any data used in the response hash calculation from UTF-8 to ISO8859-1 before sending it to Authorize, which appears to be effective in preventing the hash mismatch. The SIM form will show replacement characters ("?") for any multibyte characters sent, but the original data is retained in the order record. If someone has a better solution, please post it. I have limited time available to refine this myself.

Note that this is a patch for the Commerce version of this module. An equivalent patch will be posted to the Ubercart version's issue queue.

jerry’s picture

Linking related Ubercart module issue.

jmuessig’s picture

Sounds like a good solution to me. Thanks much for your expertise, time, and effort, Jerry!

What about the double space problem? Is that something we can strip out prior to sending to Authorize as well?

jmuessig’s picture

jerry’s picture

Multiple-space replacement is already being done:

/**
 * Convert a string potentially containing UTF-8 characters to ISO8859-1 to
 * prevent Authorize.Net hash verification issues.
 */
function _isoize($str) {
  return utf8_decode(preg_replace('/\s\s+/', ' ', trim($str)));
}
jmuessig’s picture

Ha, shows you what I know. Thanks much, Jerry! I'll give it some testing soon. :)

jmuessig’s picture

This patch works great on Ubercart; I expect it will on Commerce as well. Thanks much, Jerry!

aliod’s picture

Hello,
thanks a lot for the patch, it resolve most of the issues. But I still have issue with ampersand.
If there's a '&' in user informations like company name, the error still occurs.
I temporarily change the function _isoize to work around this problem.

function _isoize($str) {
  return utf8_decode(preg_replace(array('/\s\s+/', '/&/'), array(' ', ' '), trim($str)));
}

But :
- it can't be a permanent solution
- if the client set a '&' on the authorize interface to correct the missing one in his informations, the error occurs to.

If someone has an idea...

brightbold’s picture

I tested this patch by putting an umlaut over the "u" in my last name. It did indeed allow the transaction to go through; however, it did this by stripping my entire last name from the form. (Authnet still let me submit it on their end with the last name field blank, which was interesting.) Is this the intended behavior?

jerry’s picture

Thanks for the feedback about the ampersand, @aliod. Anyone aware of any other problematic characters that should be special-cased?

if the client set a '&' on the authorize interface to correct the missing one in his informations, the error occurs to

If you disable their ability to edit the form on the Authorize side, as suggested in the installation notes, this won't be an issue.

jerry’s picture

I tested this patch by putting an umlaut over the "u" in my last name. It did indeed allow the transaction to go through; however, it did this by stripping my entire last name from the form.

I didn't observe that behavior here. The filtering function operates on characters, not words, so I'm not sure why that would have occurred.

aliod’s picture

If you disable their ability to edit the form on the Authorize side, as suggested in the installation notes, this won't be an issue.

Thank you @jerry for your suggestion.

jerry’s picture

StatusFileSize
new4.07 KB

Here's a proper patch based on @aliod's input, with the replacement patterns switched so that multiple spaces are still removed if an ampersand is replaced.

  • jerry committed 8dacf84 on 7.x-1.x
    Issue #3030262 by jerry, BrightBold, jmuessig, aliod: Redirect hash not...
jerry’s picture

Status: Needs review » Fixed

Fixed in 7.x-1.8.

ckng’s picture

Version: 7.x-1.7 » 7.x-1.x-dev
Status: Fixed » Needs review
StatusFileSize
new796 bytes

Encountering a new hashing issue. This time is on the $message or $_GET[REDIRECT_ARG_MESSAGE].

The URL returned is

cart/authnet_simdpm/order_complete?...&msg=We%27re%20sorry%2C%20but%20due%20to%20a%20technical%20problem%2C%20your%20order%20could%20not%20be%20processed.%20Please%20try%20placing%20the%20order%20again%20later.

But has been parsed as, note the encoded "We're"

We're sorry, but due to a technical problem, your order could not be processed. Please try placing the order again later.

Attached patch fixes it.

ckng’s picture

Now having a new problem, transaction is captured but order failed at commerce_authnet_simdpm_redirect_form_validate(), called by commerce_payment_redirect_pane_checkout_form() via the drupal_goto() checkout/OID/payment/return/KEY.

Error message is
'Payment failed at the payment server. Please review your information and try again.'

function commerce_authnet_simdpm_redirect_form_validate($order, $payment_method) {
  // Should always fail, as the payment return URL should never be visited externally.
  // Visiting it via drupal_goto() (as is done normally) doesn't trigger the function.
  return FALSE;
}

So this part of the code no longer work? Any idea?

jerry’s picture

Thanks for your contribution. I'll leave it for the next maintainer to review.

jerry’s picture

Regarding your validation error: as I haven't observed this, nor has anyone else reported it, I think that it's likely to be a configuration or environmental issue unique to your implementation.

coufu’s picture

Thanks a million, ckng. Your patch at #55 works wonderfully.