The parameter for "Amount" is invalid or missing if it has more than two Fraction digits

Created on 7 May 2024, 7 months ago
Updated 15 May 2024, 6 months ago

If the currency configuration set in /admin/commerce/config/currencies has more than two decimal digits, the HyperPay error code "200.300.404" is displayed.

"description":"invalid or missing parameter",

"parameterErrors":[
{
"name":"amount",
"value":"92.000",
"message":"must match ^[0-9]{1,12}(\\.[0-9]{2})?$"
}
]

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇯🇴Jordan hamzadwaya

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @hamzadwaya
  • Status changed to Needs review 7 months ago
  • Status changed to Needs work 7 months ago
  • 🇯🇴Jordan Anas_maw

    Hello hamzadwaya,
    I think your patch still missing the same change to src/PluginForm/HyperPayCopyAndPayForm.php

    Also, my concern about this is that for orders with a total amount of 4.123 for example, if you pass 4.12 to Hayperpay, then the order status will not be paid because of 0.003 left, anyway, I think we should commit this, please make sure to fix your patch ASAP.

  • 🇯🇴Jordan hamzadwaya

    Hello Anas_maw,

    I've tested the patch for cases where the amount needs to be in two fractions. The website now shows the status as complete and displays how much the user paid. This way, the admin can see that the user paid with two digits, not three, which is the standard code from Hyperpay. and We need to implement this code from our side to complete the payment method steps

    Thank you for your observation.

  • Status changed to Needs review 6 months ago
  • 🇯🇴Jordan Anas_maw

    The latest patch added it to src/PluginForm/HyperPayCopyAndPayForm.php and the previous one added it to src/PluginForm/HyperpayForm.php

    I think we will need a single patch to add them both, right?

  • 🇯🇴Jordan hamzadwaya

    We need to add a patch to src/PluginForm/HyperPayCopyAndPayForm.php since src/PluginForm/HyperpayForm.php has been removed from the module.

  • 🇯🇴Jordan Anas_maw

    In 2.0.x branch there is src/PluginForm/HyperPayCopyAndPayForm.php

  • 🇯🇴Jordan hamzadwaya

    I retested the code for this issue and found that you are correct. The order appears as incomplete because the payment does not equal the order amount.

    I have come up with a solution for this issue in patch 3. Please review it

  • 🇯🇴Jordan hamzadwaya

    To ensure that the getPayableAmount function returns a currency value with two decimal places, we need to update the currency number to have two fractional digits. I have change to this patch

Production build 0.71.5 2024