Recalculate order just before sending user to external payment - Drupal Commerce and Paypal
14:49 07 Nov 2025

Summary: Customer could be charged a different amount from what is displayed in the Payment step panel if an auto-applied promotion gets published or unpublished just before external payment is triggered

Environment

Drupal: [10.x] Commerce: [2.x] Payment: commerce_paypal

Scenario (reproducible steps)

  1. A product has an active promotion (discount).
  2. Customer adds the product to cart and proceeds to Payment step of checkout
  3. Customer leaves the Payment page open ~1 hour (no interaction).
  4. Meanwhile, the promotion expires (automatically unpublished by a scheduler).
  5. The Payment page still shows the discounted total to the user.
  6. Customer pays via PayPal (Smart Buttons / Commerce PayPal).
  7. ISSUE: The full amount (without discount) is charged by PayPal, not the discounted total the user saw.

Result

Mismatch between displayed total and charged total → confusion, complaint, refund.

Expectation

JUST before sending the user for the remote payment, the order should be refreshed/recalculated (remove expired promo), and the user should be warned if the total changed and required to reconfirm.

Question

What is the recommended way in Drupal Commerce to:

  • Force a server-side order refresh (promotions, taxes, adjustments) right before payment authorization/creation, and Block submission + show a message if the recalculated total differs from what was displayed (e.g., promotion expired while page was open)?

Asks

Is there an existing contrib module or documented pattern in Commerce 2.x that already handles this “stale checkout page / price drift” case?

For PayPal specifically: Any way to hook ensure order is refreshed before going for external payment?

Constraints

We want to avoid charging an amount different from the confirmed UI total.

Prefer a server-side enforcement (not only JS), so payment gateways cannot be reached with stale totals.

Thanks! Any pointers to existing modules, docs, or patterns (hooks/events/panes) are appreciated.

paypal drupal drupal-commerce