Payment Method Becomes Unavailable Mid-Checkout
Problem
If a payment method's availability rules change (min/max order total, allowed countries) while customer is in checkout, they can encounter a silent failure when placing the order. The quote still has the payment method set, but it's no longer valid.
Impact
- - Order placement fails with generic error
- - Customer loses their cart configuration
- - Payment gateway may have pending authorization
Workaround
// Add validation before order placement
class ValidatePaymentPlugin
{
public function beforePlace(
\Magento\Quote\Model\QuoteManagement $subject,
CartInterface $quote,
PaymentInterface $payment = null
) {
$method = $quote->getPayment()->getMethod();
$instance = $this->methodFactory->create($method);
if (!$instance->isAvailable($quote)) {
throw new LocalizedException(
__('Selected payment method is no longer available.')
);
}
}
}