mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +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 Throwable;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\Messages;
|
||||
|
||||
/**
|
||||
* Class GatewayGenericException
|
||||
|
@ -23,7 +24,7 @@ class GatewayGenericException extends Exception {
|
|||
*/
|
||||
public function __construct( ?Throwable $inner = null ) {
|
||||
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
|
||||
);
|
||||
|
|
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(
|
||||
$wc_order,
|
||||
new Exception(
|
||||
__( 'Failed to process the payment. Please try again or contact the shop admin.', 'woocommerce-paypal-payments' )
|
||||
. ' ' . $error->getMessage(),
|
||||
Messages::generic_payment_error_message() . ' ' . $error->getMessage(),
|
||||
$error->getCode(),
|
||||
$error
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue