Problem/Motivation

I was seeing the above error on my client's live site when attempting to check out with only some products.

After filling out my credit card information and attempting to submit, the error on the checkout page says "We encountered an unexpected error processing your payment method. Please try again later." And when I check the recent log messages it says "Cancelled: Error bad character content for element 'amount' __________________".

I discovered that the only products that weren't working were the ones that ended in .00.

It turns out it was changing 10.00, for example, into 10 when a decimal number was expected. I tested the number as a string, eg. '10.00' and this was accepted. Formatting the number to two decimal places resolves the issue.

Proposed resolution

I am including a patch which uses the number_format function to properly format all amount number variables.

Remaining tasks

Patch needs review.

Release notes snippet

Fixes issue where whole number integers are rejected by the Moneris API.

Original report by embeau

I am currently seeing the above error on my client's live site when attempting to check out with only some products.

After filling out my credit card information and attempting to submit, the error on the checkout page says "We encountered an unexpected error processing your payment method. Please try again later." And when I check the recent log messages it says "Cancelled: Error bad character content for element 'amount' __________________".

We have copied the live site into a dev environment and replaced the client's live Moneris credentials with my own test store id and token. In this test environment, all products are getting this error.

The site is on Drupal 8.7.3 and using the Commerce Moneris module with on-site payment. So far we've found that only 2 out of about 16 products are getting this error. I see no issue with the amounts inputted for these products that are not working, so I do not know how to proceed from here.

Any help would be greatly appreciated. Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

embeau created an issue. See original summary.

embeau’s picture

Issue summary: View changes
embeau’s picture

Category: Support request » Bug report
Priority: Normal » Major
Issue summary: View changes
FileSize
1.41 KB

Found the issue. Was able to resolve. Issuing a patch.

rbrownell’s picture

Assigned: Unassigned » rbrownell
Status: Active » Needs review
rbrownell’s picture

Status: Needs review » Reviewed & tested by the community

  • rbrownell committed 2747ce3 on 8.x-2.x authored by embeau
    Issue #3063729 by embeau, rbrownell: Error bad character content for...
rbrownell’s picture

Assigned: rbrownell » Unassigned
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.