Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Express Checkout: amount displayed does not match charged amount #2304

Open
jonas-hoebenreich opened this issue Jan 29, 2022 · 5 comments
Open
Labels
component: payment request buttons Issues related to Payment Request Buttons - e.g. Apple Pay, Google Pay priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically.

Comments

@jonas-hoebenreich
Copy link

Describe the bug
I am currently trying to make a plugin of mine (https://wordpress.org/plugins/wc-donation-platform/) compatible with Stripe Express Checkout. In the process, I've stumbled across an issue that is causing an incorrect amount to be charged.

When Express Checkout is enabled on the product page, every time the product selection field is changed, the total amount is calculated using an AJAX request (stripe-payment-request.js, wc-ajax=wc_stripe_get_selected_product_data).
When someone clicks on the payment button, the total amount is calculated one more time (stripe-payment-request.js, wc-ajax=wc_stripe_add_to_cart).
The payment modal displays the amount calculated using wc_stripe_get_selected_product_data, but the amount calculated using wc_stripe_add_to_cart is actually charged.
Normally this is not a problem, because the two amounts are the same, but if the amounts differ the user's trust in the Google Pay modal is betrayed.

To Reproduce
Steps to reproduce the behavior:

  1. Activate Stripe Express Checkout for Product Pages
  2. Add the following PHP code:
add_action( 'woocommerce_before_calculate_totals', function($cart_object) {
	foreach ( $cart_object->cart_contents as $key => $value ) {
		$value['data']->set_price(9999);
	}
} );
  1. Click the Google Pay button on a product page. In this example, the product costs $1 (Screenshot 1)
  2. The wrong amount is charged (Screenshot 2)

Expected behavior
The amount displayed in the Google Pay window matches the charged amount. At the very least, some form of error message should pop up.

Screenshots
Screenshot 1:
Clipboard01

Screenshot 2:
Clipboard02

Environment (please complete the following information):

  • WordPress Version: 5.9
  • WooCommerce Version: 6.1.1
  • Stripe Plugin Version: 6.1.0
  • Browser [e.g. chrome, safari] and Version: Chrome 97.0.4692.71

Additional context
By the way, the Express Checkout handling is implemented much more elegantly by the official PayPal plugin (the amount is calculated only once when clicking the button, which saves server resources.)
In addition, it is easier to pass additional individual parameters, because PayPal sends all parameters matching "[name^='attribute_']". Stripe uses $(".variations_form").find(".variations select") here, which makes it much more difficult, because the same selectors are also used by WooCommerce itself, which causes conflicts if you want to sneak additional parameters along. This makes it much easier to make WooCommerce PayPal Payments compatible with other plugins.

@PoeHaH
Copy link

PoeHaH commented Feb 22, 2022

This issue is related to the one I describe here: #2322

@rafaelzaleski rafaelzaleski added component: payment request buttons Issues related to Payment Request Buttons - e.g. Apple Pay, Google Pay priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. labels Mar 9, 2022
Copy link

Hi,
This issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.

@PoeHaH
Copy link

PoeHaH commented Nov 30, 2024

Hi,

Afaik this has not been solved. It feels like the authors deliberately want to keep this functionality closed so tons of (non-Woo) plugins can not properly integrate?

@isitgeorge
Copy link

This is causing a bit of a headache for some custom functionality I'm working on where the item price is calculated depending on data the customer provides via cart_item_data.

I too am calculating this as part of the woocommerce_before_calculate_totals action which is respected by normal card payments via Stripe, but not express checkout options like Apple Pay.

What is the solution/workaround for this? None of the threads I've read actually specify how/when express payments fetch the cart total - is there an earlier action I should be using instead of woocommerce_before_calculate_totals?

Appreciate any help!

@isitgeorge
Copy link

@jonas-hoebenreich Did you find a workaround or solution for this issue in the end, or did you end up disabling Stripe Express Checkouts? Cheers

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component: payment request buttons Issues related to Payment Request Buttons - e.g. Apple Pay, Google Pay priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically.
Projects
None yet
Development

No branches or pull requests

4 participants