Add logger to Apple Pay and Google Pay gateways

This commit is contained in:
Emili Castells Guasch 2024-08-29 11:38:40 +02:00
parent dfecfb8723
commit 888d9126f5
4 changed files with 28 additions and 4 deletions

View file

@ -306,7 +306,8 @@ return array(
$container->get( 'wcgateway.processor.refunds' ), $container->get( 'wcgateway.processor.refunds' ),
$container->get( 'wcgateway.transaction-url-provider' ), $container->get( 'wcgateway.transaction-url-provider' ),
$container->get( 'session.handler' ), $container->get( 'session.handler' ),
$container->get( 'applepay.url' ) $container->get( 'applepay.url' ),
$container->get( 'woocommerce.logger.woocommerce' )
); );
}, },

View file

@ -10,6 +10,7 @@ declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Applepay; namespace WooCommerce\PayPalCommerce\Applepay;
use Exception; use Exception;
use Psr\Log\LoggerInterface;
use WC_Order; use WC_Order;
use WC_Payment_Gateway; use WC_Payment_Gateway;
use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler;
@ -72,6 +73,13 @@ class ApplePayGateway extends WC_Payment_Gateway {
*/ */
private $module_url; private $module_url;
/**
* The logger.
*
* @var LoggerInterface
*/
private $logger;
/** /**
* ApplePayGateway constructor. * ApplePayGateway constructor.
* *
@ -84,6 +92,7 @@ class ApplePayGateway extends WC_Payment_Gateway {
* view URL based on order. * view URL based on order.
* @param SessionHandler $session_handler The Session Handler. * @param SessionHandler $session_handler The Session Handler.
* @param string $module_url The URL to the module. * @param string $module_url The URL to the module.
* @param LoggerInterface $logger The logger.
*/ */
public function __construct( public function __construct(
OrderProcessor $order_processor, OrderProcessor $order_processor,
@ -91,7 +100,8 @@ class ApplePayGateway extends WC_Payment_Gateway {
RefundProcessor $refund_processor, RefundProcessor $refund_processor,
TransactionUrlProvider $transaction_url_provider, TransactionUrlProvider $transaction_url_provider,
SessionHandler $session_handler, SessionHandler $session_handler,
string $module_url string $module_url,
LoggerInterface $logger
) { ) {
$this->id = self::ID; $this->id = self::ID;
@ -111,6 +121,7 @@ class ApplePayGateway extends WC_Payment_Gateway {
$this->refund_processor = $refund_processor; $this->refund_processor = $refund_processor;
$this->transaction_url_provider = $transaction_url_provider; $this->transaction_url_provider = $transaction_url_provider;
$this->session_handler = $session_handler; $this->session_handler = $session_handler;
$this->logger = $logger;
add_action( add_action(
'woocommerce_update_options_payment_gateways_' . $this->id, 'woocommerce_update_options_payment_gateways_' . $this->id,

View file

@ -267,7 +267,8 @@ return array(
$container->get( 'wcgateway.processor.refunds' ), $container->get( 'wcgateway.processor.refunds' ),
$container->get( 'wcgateway.transaction-url-provider' ), $container->get( 'wcgateway.transaction-url-provider' ),
$container->get( 'session.handler' ), $container->get( 'session.handler' ),
$container->get( 'googlepay.url' ) $container->get( 'googlepay.url' ),
$container->get( 'woocommerce.logger.woocommerce' )
); );
}, },
); );

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay; namespace WooCommerce\PayPalCommerce\Googlepay;
use Exception; use Exception;
use Psr\Log\LoggerInterface;
use WC_Order; use WC_Order;
use WC_Payment_Gateway; use WC_Payment_Gateway;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException; use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
@ -72,6 +73,13 @@ class GooglePayGateway extends WC_Payment_Gateway {
*/ */
private $module_url; private $module_url;
/**
* The logger.
*
* @var LoggerInterface
*/
private $logger;
/** /**
* GooglePayGateway constructor. * GooglePayGateway constructor.
* *
@ -81,6 +89,7 @@ class GooglePayGateway extends WC_Payment_Gateway {
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order. * @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
* @param SessionHandler $session_handler The Session Handler. * @param SessionHandler $session_handler The Session Handler.
* @param string $module_url The URL to the module. * @param string $module_url The URL to the module.
* @param LoggerInterface $logger The logger.
*/ */
public function __construct( public function __construct(
OrderProcessor $order_processor, OrderProcessor $order_processor,
@ -88,7 +97,8 @@ class GooglePayGateway extends WC_Payment_Gateway {
RefundProcessor $refund_processor, RefundProcessor $refund_processor,
TransactionUrlProvider $transaction_url_provider, TransactionUrlProvider $transaction_url_provider,
SessionHandler $session_handler, SessionHandler $session_handler,
string $module_url string $module_url,
LoggerInterface $logger
) { ) {
$this->id = self::ID; $this->id = self::ID;
@ -113,6 +123,7 @@ class GooglePayGateway extends WC_Payment_Gateway {
$this->refund_processor = $refund_processor; $this->refund_processor = $refund_processor;
$this->transaction_url_provider = $transaction_url_provider; $this->transaction_url_provider = $transaction_url_provider;
$this->session_handler = $session_handler; $this->session_handler = $session_handler;
$this->logger = $logger;
add_action( add_action(
'woocommerce_update_options_payment_gateways_' . $this->id, 'woocommerce_update_options_payment_gateways_' . $this->id,