mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add return-url error logging
This commit is contained in:
parent
af5d33dc78
commit
e3bd42b93b
2 changed files with 23 additions and 5 deletions
|
@ -942,7 +942,8 @@ return array(
|
||||||
return new ReturnUrlEndpoint(
|
return new ReturnUrlEndpoint(
|
||||||
$gateway,
|
$gateway,
|
||||||
$endpoint,
|
$endpoint,
|
||||||
$prefix
|
$prefix,
|
||||||
|
$container->get( 'woocommerce.logger.woocommerce' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\WcGateway\Endpoint;
|
namespace WooCommerce\PayPalCommerce\WcGateway\Endpoint;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOGateway;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
|
@ -36,17 +37,31 @@ class ReturnUrlEndpoint {
|
||||||
*/
|
*/
|
||||||
private $order_endpoint;
|
private $order_endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger.
|
||||||
|
*
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReturnUrlEndpoint constructor.
|
* ReturnUrlEndpoint constructor.
|
||||||
*
|
*
|
||||||
* @param PayPalGateway $gateway The PayPal Gateway.
|
* @param PayPalGateway $gateway The PayPal Gateway.
|
||||||
* @param OrderEndpoint $order_endpoint The Order Endpoint.
|
* @param OrderEndpoint $order_endpoint The Order Endpoint.
|
||||||
* @param string $prefix The prefix.
|
* @param string $prefix The prefix.
|
||||||
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct( PayPalGateway $gateway, OrderEndpoint $order_endpoint, string $prefix ) {
|
public function __construct(
|
||||||
|
PayPalGateway $gateway,
|
||||||
|
OrderEndpoint $order_endpoint,
|
||||||
|
string $prefix,
|
||||||
|
LoggerInterface $logger
|
||||||
|
) {
|
||||||
$this->gateway = $gateway;
|
$this->gateway = $gateway;
|
||||||
$this->order_endpoint = $order_endpoint;
|
$this->order_endpoint = $order_endpoint;
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,11 +80,13 @@ class ReturnUrlEndpoint {
|
||||||
|
|
||||||
$wc_order_id = $this->sanitize_custom_id( $order->purchase_units()[0]->custom_id() );
|
$wc_order_id = $this->sanitize_custom_id( $order->purchase_units()[0]->custom_id() );
|
||||||
if ( ! $wc_order_id ) {
|
if ( ! $wc_order_id ) {
|
||||||
|
$this->logger->warning( "Return URL endpoint $token: no WC order ID." );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$wc_order = wc_get_order( $wc_order_id );
|
$wc_order = wc_get_order( $wc_order_id );
|
||||||
if ( ! is_a( $wc_order, \WC_Order::class ) ) {
|
if ( ! is_a( $wc_order, \WC_Order::class ) ) {
|
||||||
|
$this->logger->warning( "Return URL endpoint $token: WC order $wc_order_id not found." );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue