mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Log delete payment failure and parse url when checking payments page
This commit is contained in:
parent
28b12af089
commit
773b784a53
3 changed files with 15 additions and 3 deletions
|
@ -35,7 +35,8 @@ return array(
|
||||||
'vaulting.endpoint.delete' => function( $container ) : DeletePaymentTokenEndpoint {
|
'vaulting.endpoint.delete' => function( $container ) : DeletePaymentTokenEndpoint {
|
||||||
return new DeletePaymentTokenEndpoint(
|
return new DeletePaymentTokenEndpoint(
|
||||||
$container->get( 'vaulting.repository.payment-token' ),
|
$container->get( 'vaulting.repository.payment-token' ),
|
||||||
$container->get( 'button.request-data' )
|
$container->get( 'button.request-data' ),
|
||||||
|
$container->get( 'woocommerce.logger.woocommerce' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||||
namespace WooCommerce\PayPalCommerce\Vaulting\Endpoint;
|
namespace WooCommerce\PayPalCommerce\Vaulting\Endpoint;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
||||||
use WooCommerce\PayPalCommerce\Vaulting\PaymentTokenRepository;
|
use WooCommerce\PayPalCommerce\Vaulting\PaymentTokenRepository;
|
||||||
|
|
||||||
|
@ -34,15 +35,24 @@ class DeletePaymentTokenEndpoint {
|
||||||
*/
|
*/
|
||||||
protected $request_data;
|
protected $request_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger.
|
||||||
|
*
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeletePaymentTokenEndpoint constructor.
|
* DeletePaymentTokenEndpoint constructor.
|
||||||
*
|
*
|
||||||
* @param PaymentTokenRepository $repository The repository.
|
* @param PaymentTokenRepository $repository The repository.
|
||||||
* @param RequestData $request_data The request data.
|
* @param RequestData $request_data The request data.
|
||||||
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct( PaymentTokenRepository $repository, RequestData $request_data ) {
|
public function __construct( PaymentTokenRepository $repository, RequestData $request_data, LoggerInterface $logger ) {
|
||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
$this->request_data = $request_data;
|
$this->request_data = $request_data;
|
||||||
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +86,7 @@ class DeletePaymentTokenEndpoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch ( Exception $error ) {
|
} catch ( Exception $error ) {
|
||||||
|
$this->logger->error( 'Failed to delete payment: ' . $error->getMessage() );
|
||||||
wp_send_json_error( $error->getMessage(), 403 );
|
wp_send_json_error( $error->getMessage(), 403 );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ class VaultingModule implements ModuleInterface {
|
||||||
*/
|
*/
|
||||||
private function is_payments_page(): bool {
|
private function is_payments_page(): bool {
|
||||||
global $wp;
|
global $wp;
|
||||||
$request = explode( '/', $wp->request );
|
$request = explode( '/', wp_parse_url( $wp->request, PHP_URL_PATH ) );
|
||||||
if ( end( $request ) === 'ppcp-paypal-payment-tokens' ) {
|
if ( end( $request ) === 'ppcp-paypal-payment-tokens' ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue