Skip to main content

#119 Payment confirmation fails when the price of the order was quoted to two decimal places

Posted in ‘Stripe Checkout for VirtueMart’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information (available for public)

PHP version
8.2.12

Latest post by sulpher on Tuesday, 09 July 2024 08:35 EEST

Dentapreg

Hello,

we have a problem with your VirtueMart Stripe Checkout plugin. When an order comes in with an order price to two decimal places (for example $164.64 instead of $164.00.) the order payment confirmation fails. The error in the log is "plg_vmpayment_vmstripeco eventSessionCompleted, amount is not the same:". But the amount is the same.

While searching for the error, we came across a possible cause: float values are compared and are slightly different, as is usual for floating point numbers.

Is there any way to fix it?

Thanks in advance!

David

b2z

Hi David!

We are always testing our plugins with the different order amounts and did not face the issue. Just checked on our test website the amount 175,82 € and it was confirmed without an error.

But if you have an issue then indeed we need to fix it.

Can you please share what amount do you have after amount is not the same in the log and what is the order amount.

Also enable "Debug" in the payment method settings to get the extended logging.

Kind regards,

Dmitrijs

sulpher
Hello David,
In addition to Dmitrijs' message I'd like to ask: did you use coupon code? Is there any tax rate added to the shop? We need to reproduce the same issue on our environment and need more details.

Best regards,
Eugene

Dentapreg

Hi Dmitrijs and Eugene,

The exact amount is $162.64. The coupon was not used, but the tax rate was applied: 7% on each product and shipping (Florida sales tax). I just turned on debug mode, later in the day I can make a test payment with the same products and amount with debug mode turned on.

Thanks for your help,

David

Dentapreg

Here are the extended logs:

2024-07-03T10:54:44+00:00    DEBUG 54.187.205.235    plg_vmpayment_vmstripeco    eventSessionCompleted, session data: Stripe\Checkout\Session Object
(
    [id] => XXXX
    [object] => checkout.session
    [after_expiration] => 
    [allow_promotion_codes] => 
    [amount_subtotal] => 16264
    [amount_total] => 16264
    [automatic_tax] => Stripe\StripeObject Object
        (
            [enabled] => 
            [liability] => 
            [status] => 
        )
    [billing_address_collection] => 
    [cancel_url] => https://adm.dental/index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&pm=14&on=24000860
    [client_reference_id] => 337
    [client_secret] => 
    [consent] => 
    [consent_collection] => 
    [created] => 1720004003
    [currency] => usd
    [currency_conversion] => 
    [custom_fields] => Array
        (
        )
    [custom_text] => Stripe\StripeObject Object
        (
            [after_submit] => 
            [shipping_address] => 
            [submit] => 
            [terms_of_service_acceptance] => 
        )
    [customer] => 
    [customer_creation] => if_required
    [customer_details] => Stripe\StripeObject Object
        (
            [address] => Stripe\StripeObject Object
                (
                    [city] => 
                    [country] => US
                    [line1] => 
                    [line2] => 
                    [postal_code] => 34237
                    [state] => 
                )
            [email] => david@dentapreg.com
            [name] => Zbyněk Šedivý
            [phone] => 
            [tax_exempt] => none
            [tax_ids] => Array
                (
                )
        )
    [customer_email] => david@dentapreg.com
    [expires_at] => 1720090402
    [invoice] => 
    [invoice_creation] => Stripe\StripeObject Object
        (
            [enabled] => 
            [invoice_data] => Stripe\StripeObject Object
                (
                    [account_tax_ids] => 
                    [custom_fields] => 
                    [description] => 
                    [footer] => 
                    [issuer] => 
                    [metadata] => Stripe\StripeObject Object
                        (
                        )
                    [rendering_options] => 
                )
        )
    [livemode] => 1
    [locale] => 
    [metadata] => Stripe\StripeObject Object
        (
            [order_id] => 337
        )
    [mode] => payment
    [payment_intent] => XXXXX
    [payment_link] => 
    [payment_method_collection] => if_required
    [payment_method_configuration_details] => Stripe\StripeObject Object
        (
            [id] => XXXX
            [parent] => 
        )
    [payment_method_options] => Stripe\StripeObject Object
        (
            [card] => Stripe\StripeObject Object
                (
                    [request_three_d_secure] => automatic
                )
        )
    [payment_method_types] => Array
        (
            [0] => card
            [1] => afterpay_clearpay
            [2] => klarna
            [3] => link
            [4] => affirm
            [5] => cashapp
        )
    [payment_status] => paid
    [phone_number_collection] => Stripe\StripeObject Object
        (
            [enabled] => 
        )
    [recovered_from] => 
    [saved_payment_method_options] => 
    [setup_intent] => 
    [shipping_address_collection] => 
    [shipping_cost] => 
    [shipping_details] => 
    [shipping_options] => Array
        (
        )
    [status] => complete
    [submit_type] => 
    [subscription] => 
    [success_url] => https://adm.dental/index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=14&on=24000860
    [total_details] => Stripe\StripeObject Object
        (
            [amount_discount] => 0
            [amount_shipping] => 0
            [amount_tax] => 0
        )
    [ui_mode] => hosted
    [url] => 
)
2024-07-03T10:54:44+00:00    ERROR 54.187.205.235    plg_vmpayment_vmstripeco    eventSessionCompleted, amount is not the same: 162.64

b2z

David,

Thank you. That's strange. Need to figure out why this happens. 16264 is the correct amount...

b2z

David, do you have access to your database?

There is a table virtuemart_payment_plg_vmstripeco where the order data processed by the payment plugin is stored. What value do you have for this order in payment_order_total column?

It might be that there is something wrong with compared numbers, but the problem is that we cannot replicate on our test website and need your data to find out where the issue is hidden.

Kind regards,

Dmitrijs

Yes, I do. It's the same value (162.64).

https://drive.google.com/file/d/1JqG_U9Fleuo0wllAtWVLzkgzaGGvPOv5/view?usp=sharing

b2z

Well...

I am kinda stuck as we have different decimal values with our tests and no error with the amount validation. Will test exactly 162.64...

Kind regards,

Dmitrijs

b2z

Well I do not know why, but for PHP 16264 does not equal 16264 and 15698 does not equal 15698... So if number ends on .62 or .98 and compared as cents (like multiply on 100) then it fails... Crazy thing.

I remade the amount check and test for 162.64 also has passed. Wait for the release of fixed version.

Kind regards,

Dmitrijs

b2z

New version 1.1.1 has been released. It should fix the issue with the amount validation.

Kind regards,

Dmitrijs

Sorry for the late reply, I've been out of work. 

Thank you very much for your help and fix! 

Sincerely,

David

sulpher

Hi David,

We would be grateful if you leave a review about our plugin at the Joomla Extensions Directory.

 

Have a good day,

Eugene

Support information

Support hours: You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+3), but not limited. Our staff is pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days.


Our time: / Your time:

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. We also ask you to remove temporary credentials at your site after the problem is resolved. Thank you.

Support of free extensions is not provided on this forum. Please submit your questions or report issues via Github tracker. See link on the product page.