Reducing the order total to 0 after creating a payment intent results in payment with previous amount

Created on 14 April 2023, over 2 years ago
Updated 1 May 2023, over 2 years ago

Problem/Motivation

When a user provides a credit card, proceeds to checkout and then there or back on an earlier step uses a coupon, giftcard or similar feature to reduce the order price to 0, the payment intent fails to update the amount to zero in \Drupal\commerce_stripe\EventSubscriber\OrderPaymentIntentSubscriber::destruct() because that's not a valid amount.

The review pane will not sync/check the total price paid and confirm the previous payment. This will not create a payment and the payment is not visible in the order.

Steps to reproduce

Proposed resolution

The payment confirmation happens on the review pane through JS, skip that if the order total price is zero.

Remaining tasks

Some/all of these are possibly less-critical follow-ups:

* Cancel the payment intent if a zero-price order with a connected payment intent is placed.
* Improve the amount sync. Check for amount for 0, don't even try then, check for same amount to avoid extra API requests, log failing errors.
* Verify the price of the intent on the review pane?

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇭Switzerland berdir Switzerland

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

Comments & Activities

Production build 0.71.5 2024