Problem/Motivation
In both PaymentElement and CardElement, when a PaymentIntent reaches a non-terminal, non-success status and last_payment_error is absent (null), we assign $decline_message = $intent->last_payment_error, leaving $decline_message as null. Passing null to the string $message parameter of HardDeclineException::createForPayment() throws a TypeError in PHP 8.2+.
Even in prior versions of PHP, this isn't really right, as we end up passing an empty string as the Hard Decline message.
If $intent->last_payment_error is not an object(and therefore NULL), we should return a friendlier error message.
Additionally, CardElement is on;your checking for the deprecated $intent->charges->data, and not the newer $intent->latest_charge, like PaymentElement.
We should make the handling here more consistent.
Note: we aren't carrying over other enhancements from PaymentElement to CardElement, like handling the processing status, as this is not applicable to card payment methods, which is the only payment method type supported by the CardElement.
Issue fork commerce_stripe-3591853
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
tomtech commented