mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Delete transients stored while user is logged in
This commit is contained in:
parent
c68db5c1a1
commit
22c2b5afd4
2 changed files with 23 additions and 2 deletions
|
@ -1662,12 +1662,15 @@ return array(
|
|||
$container->get( 'wcgateway.settings' )
|
||||
);
|
||||
},
|
||||
'api.client-credentials-cache' => static function( ContainerInterface $container ): Cache {
|
||||
return new Cache( 'ppcp-client-credentials-cache' );
|
||||
},
|
||||
'api.user-id-token' => static function( ContainerInterface $container ): UserIdToken {
|
||||
return new UserIdToken(
|
||||
$container->get( 'api.host' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
$container->get( 'api.client-credentials' ),
|
||||
new Cache( 'ppcp-client-credentials-cache' )
|
||||
$container->get( 'api.client-credentials-cache' )
|
||||
);
|
||||
},
|
||||
'api.sdk-client-token' => static function( ContainerInterface $container ): SdkClientToken {
|
||||
|
@ -1675,7 +1678,7 @@ return array(
|
|||
$container->get( 'api.host' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
$container->get( 'api.client-credentials' ),
|
||||
new Cache( 'ppcp-client-credentials-cache' )
|
||||
$container->get( 'api.client-credentials-cache' )
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -10,6 +10,9 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\ApiClient;
|
||||
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\SdkClientToken;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\UserIdToken;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderTransient;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
||||
|
@ -94,6 +97,21 @@ class ApiModule implements ModuleInterface {
|
|||
10,
|
||||
2
|
||||
);
|
||||
|
||||
add_action(
|
||||
'wp_logout',
|
||||
function() use ( $c ) {
|
||||
$client_credentials_cache = $c->get( 'api.client-credentials-cache' );
|
||||
assert( $client_credentials_cache instanceof Cache );
|
||||
|
||||
if ( $client_credentials_cache->has( UserIdToken::CACHE_KEY ) ) {
|
||||
$client_credentials_cache->delete( UserIdToken::CACHE_KEY );
|
||||
}
|
||||
if ( $client_credentials_cache->has( SdkClientToken::CACHE_KEY ) ) {
|
||||
$client_credentials_cache->delete( SdkClientToken::CACHE_KEY );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue