- Issue created by @mhawwari
- π―π΄Jordan mhawwari
mhawwari β changed the visibility of the branch 3444153-isexpired-aborts-payments to hidden.
- π―π΄Jordan mhawwari
mhawwari β changed the visibility of the branch 3444153-isexpired-aborts-payments to active.
- Issue was unassigned.
- Status changed to Needs review
9 months ago 7:10am 30 April 2024 - π¬π§United Kingdom jonathanshaw Stroud, UK
This closely relates to #3171270: Support 'smarter saved cards' β with same proposed solution.
- First commit to issue fork.
- Assigned to TomTech
- πΊπΈUnited States TomTech
This is reasonable.
In the past, sites were expected to not submit expired cards for payment, as it appeared as suspicious activity. Fraud prevention measures have evolved.
Even if the expired date is "valid", the card could have been reported lost/stolen and the card would still not work anyway.
Thanks for the MR!
-
TomTech β
committed 21435daf on 8.x-1.x authored by
mhawwari β
Issue #3444153 by mhawwari, TomTech, jonathanshaw: isExpired aborts...
-
TomTech β
committed 21435daf on 8.x-1.x authored by
mhawwari β
- Status changed to Fixed
8 months ago 1:57am 18 June 2024 - Status changed to Needs work
8 months ago 9:00am 18 June 2024 - π¬π§United Kingdom jonathanshaw Stroud, UK
The fix may be wrong.
PaymentGatewayBase has this:
protected function assertPaymentMethod(PaymentMethodInterface $payment_method = NULL) { if (empty($payment_method)) { throw new \InvalidArgumentException('The provided payment has no payment method referenced.'); } if ($payment_method->isExpired()) { throw HardDeclineException::createForPayment($payment_method, 'The provided payment method has expired'); } }
Wouldn't the correct solution be to keep the calls to assertPaymenMethod() but to override and simplify the method:
/** * {@inheritdoc} */ protected function assertPaymentMethod(PaymentMethodInterface $payment_method = NULL) { if (empty($payment_method)) { throw new \InvalidArgumentException('The provided payment has no payment method referenced.'); } }
- Status changed to Fixed
8 months ago 11:35am 18 June 2024 - πΊπΈUnited States TomTech
Hi @jonathanshaw,
That would seem so, except the preceding line in both classes was already doing:
assert($payment_method instanceof PaymentMethodInterface); $this->assertPaymentMethod($payment_method);
Because of the assert, payment_method would already be checked for existence, so that would be a redundant check that would never be true.
One could discuss whether assert() should be used at all, but it has been there for ~5 years, and would be more appropriate for another issue to discuss assert() usage.
Automatically closed - issue fixed for 2 weeks with no activity.