mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Extract error message
This commit is contained in:
parent
81c786150d
commit
0ce3af03c3
3 changed files with 30 additions and 3 deletions
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Exception;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\Messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GatewayGenericException
|
* Class GatewayGenericException
|
||||||
|
@ -23,7 +24,7 @@ class GatewayGenericException extends Exception {
|
||||||
*/
|
*/
|
||||||
public function __construct( ?Throwable $inner = null ) {
|
public function __construct( ?Throwable $inner = null ) {
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
__( 'Failed to process the payment. Please try again or contact the shop admin.', 'woocommerce-paypal-payments' ),
|
Messages::generic_payment_error_message(),
|
||||||
$inner ? (int) $inner->getCode() : 0,
|
$inner ? (int) $inner->getCode() : 0,
|
||||||
$inner
|
$inner
|
||||||
);
|
);
|
||||||
|
|
27
modules/ppcp-wc-gateway/src/Gateway/Messages.php
Normal file
27
modules/ppcp-wc-gateway/src/Gateway/Messages.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Common messages.
|
||||||
|
*
|
||||||
|
* @package WooCommerce\PayPalCommerce\WcGateway\Gateway
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Messages
|
||||||
|
*/
|
||||||
|
class Messages {
|
||||||
|
/**
|
||||||
|
* The generic payment failure message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function generic_payment_error_message(): string {
|
||||||
|
return apply_filters(
|
||||||
|
'woocommerce_paypal_payments_generic_payment_error_message',
|
||||||
|
__( 'Failed to process the payment. Please try again or contact the shop admin.', 'woocommerce-paypal-payments' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -232,8 +232,7 @@ trait ProcessPaymentTrait {
|
||||||
return $this->handle_payment_failure(
|
return $this->handle_payment_failure(
|
||||||
$wc_order,
|
$wc_order,
|
||||||
new Exception(
|
new Exception(
|
||||||
__( 'Failed to process the payment. Please try again or contact the shop admin.', 'woocommerce-paypal-payments' )
|
Messages::generic_payment_error_message() . ' ' . $error->getMessage(),
|
||||||
. ' ' . $error->getMessage(),
|
|
||||||
$error->getCode(),
|
$error->getCode(),
|
||||||
$error
|
$error
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue