Skip to content
Snippets Groups Projects

Issue #3112812: Add logging for payment failures during checkout

Merged Dmytrii Kaiun requested to merge issue/commerce-3112812:3112812-add-logging-for into 8.x-2.x
1 file
+ 8
6
Compare changes
  • Side-by-side
  • Inline
@@ -97,7 +97,7 @@ class PaymentMethodEditForm extends PaymentMethodFormBase {
$payment_gateway_plugin->updatePaymentMethod($payment_method);
$payment_method->save();
}
catch (DeclineException $e) {
catch (PaymentGatewayException $e) {
if (
$this->order instanceof OrderInterface &&
$payment_method->getPaymentGateway() instanceof PaymentGatewayInterface
@@ -106,11 +106,13 @@ class PaymentMethodEditForm extends PaymentMethodFormBase {
$this->eventDispatcher->dispatch($event, PaymentEvents::PAYMENT_FAILURE);
}
$this->logger->warning($e->getMessage());
throw new DeclineException(t('We encountered an error processing your payment method. Please verify your details and try again.'));
}
catch (PaymentGatewayException $e) {
$this->logger->error($e->getMessage());
throw new PaymentGatewayException(t('We encountered an unexpected error processing your payment method. Please try again later.'));
$message = $e instanceof DeclineException ?
$this->t('We encountered an error processing your payment method. Please verify your details and try again.') :
$this->t('We encountered an unexpected error processing your payment. Please try again later.');
// Rethrow the original exception with a new message for security reasons.
throw new (get_class($e))($message);
}
}
Loading