mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
delete cache when receiving client_id and secret from paypal
This commit is contained in:
parent
34aab23f4e
commit
1db589644a
2 changed files with 15 additions and 14 deletions
|
@ -11,18 +11,6 @@ use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||||
use Inpsyde\PayPalCommerce\Onboarding\Assets\OnboardingAssets;
|
use Inpsyde\PayPalCommerce\Onboarding\Assets\OnboardingAssets;
|
||||||
use Inpsyde\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
|
use Inpsyde\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
|
||||||
use Inpsyde\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
use Inpsyde\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderDetail;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGatewayBase;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
|
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsFields;
|
|
||||||
use WpOop\TransientCache\CachePoolFactory;
|
use WpOop\TransientCache\CachePoolFactory;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -113,11 +101,16 @@ return [
|
||||||
$loginSellerEndpoint = $container->get('api.endpoint.login-seller');
|
$loginSellerEndpoint = $container->get('api.endpoint.login-seller');
|
||||||
$partnerReferralsData = $container->get('api.repository.partner-referrals-data');
|
$partnerReferralsData = $container->get('api.repository.partner-referrals-data');
|
||||||
$settings = $container->get('wcgateway.settings');
|
$settings = $container->get('wcgateway.settings');
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$cacheFactory = new CachePoolFactory($wpdb);
|
||||||
|
$pool = $cacheFactory->createCachePool('ppcp-token');
|
||||||
return new LoginSellerEndpoint(
|
return new LoginSellerEndpoint(
|
||||||
$requestData,
|
$requestData,
|
||||||
$loginSellerEndpoint,
|
$loginSellerEndpoint,
|
||||||
$partnerReferralsData,
|
$partnerReferralsData,
|
||||||
$settings
|
$settings,
|
||||||
|
$pool
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'onboarding.render' => static function (ContainerInterface $container) : OnboardingRenderer {
|
'onboarding.render' => static function (ContainerInterface $container) : OnboardingRenderer {
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Inpsyde\PayPalCommerce\Onboarding\Endpoint;
|
namespace Inpsyde\PayPalCommerce\Onboarding\Endpoint;
|
||||||
|
|
||||||
|
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||||
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\LoginSeller;
|
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\LoginSeller;
|
||||||
use Inpsyde\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
use Inpsyde\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
||||||
use Inpsyde\PayPalCommerce\Button\Endpoint\EndpointInterface;
|
use Inpsyde\PayPalCommerce\Button\Endpoint\EndpointInterface;
|
||||||
|
@ -11,6 +12,7 @@ use Inpsyde\PayPalCommerce\Button\Endpoint\RequestData;
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGatewayInterface;
|
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGatewayInterface;
|
||||||
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
|
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||||
|
use Psr\SimpleCache\CacheInterface;
|
||||||
|
|
||||||
class LoginSellerEndpoint implements EndpointInterface
|
class LoginSellerEndpoint implements EndpointInterface
|
||||||
{
|
{
|
||||||
|
@ -20,17 +22,20 @@ class LoginSellerEndpoint implements EndpointInterface
|
||||||
private $loginSellerEndpoint;
|
private $loginSellerEndpoint;
|
||||||
private $partnerReferralsData;
|
private $partnerReferralsData;
|
||||||
private $settings;
|
private $settings;
|
||||||
|
private $cache;
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RequestData $requestData,
|
RequestData $requestData,
|
||||||
LoginSeller $loginSellerEndpoint,
|
LoginSeller $loginSellerEndpoint,
|
||||||
PartnerReferralsData $partnerReferralsData,
|
PartnerReferralsData $partnerReferralsData,
|
||||||
Settings $settings
|
Settings $settings,
|
||||||
|
CacheInterface $cache
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->requestData = $requestData;
|
$this->requestData = $requestData;
|
||||||
$this->loginSellerEndpoint = $loginSellerEndpoint;
|
$this->loginSellerEndpoint = $loginSellerEndpoint;
|
||||||
$this->partnerReferralsData = $partnerReferralsData;
|
$this->partnerReferralsData = $partnerReferralsData;
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
$this->cache = $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nonce(): string
|
public static function nonce(): string
|
||||||
|
@ -51,6 +56,9 @@ class LoginSellerEndpoint implements EndpointInterface
|
||||||
$this->settings->set('client_secret', $credentials->client_secret);
|
$this->settings->set('client_secret', $credentials->client_secret);
|
||||||
$this->settings->set('client_id', $credentials->client_id);
|
$this->settings->set('client_id', $credentials->client_id);
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
|
if ($this->cache->has(PayPalBearer::CACHE_KEY)) {
|
||||||
|
$this->cache->delete(PayPalBearer::CACHE_KEY);
|
||||||
|
}
|
||||||
wp_schedule_single_event(
|
wp_schedule_single_event(
|
||||||
time() - 1,
|
time() - 1,
|
||||||
WebhookRegistrar::EVENT_HOOK
|
WebhookRegistrar::EVENT_HOOK
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue