mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +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\Endpoint\LoginSellerEndpoint;
|
||||
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;
|
||||
|
||||
return [
|
||||
|
@ -113,11 +101,16 @@ return [
|
|||
$loginSellerEndpoint = $container->get('api.endpoint.login-seller');
|
||||
$partnerReferralsData = $container->get('api.repository.partner-referrals-data');
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
|
||||
global $wpdb;
|
||||
$cacheFactory = new CachePoolFactory($wpdb);
|
||||
$pool = $cacheFactory->createCachePool('ppcp-token');
|
||||
return new LoginSellerEndpoint(
|
||||
$requestData,
|
||||
$loginSellerEndpoint,
|
||||
$partnerReferralsData,
|
||||
$settings
|
||||
$settings,
|
||||
$pool
|
||||
);
|
||||
},
|
||||
'onboarding.render' => static function (ContainerInterface $container) : OnboardingRenderer {
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Inpsyde\PayPalCommerce\Onboarding\Endpoint;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\LoginSeller;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
||||
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\Settings\Settings;
|
||||
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class LoginSellerEndpoint implements EndpointInterface
|
||||
{
|
||||
|
@ -20,17 +22,20 @@ class LoginSellerEndpoint implements EndpointInterface
|
|||
private $loginSellerEndpoint;
|
||||
private $partnerReferralsData;
|
||||
private $settings;
|
||||
private $cache;
|
||||
public function __construct(
|
||||
RequestData $requestData,
|
||||
LoginSeller $loginSellerEndpoint,
|
||||
PartnerReferralsData $partnerReferralsData,
|
||||
Settings $settings
|
||||
Settings $settings,
|
||||
CacheInterface $cache
|
||||
) {
|
||||
|
||||
$this->requestData = $requestData;
|
||||
$this->loginSellerEndpoint = $loginSellerEndpoint;
|
||||
$this->partnerReferralsData = $partnerReferralsData;
|
||||
$this->settings = $settings;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
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_id', $credentials->client_id);
|
||||
$this->settings->persist();
|
||||
if ($this->cache->has(PayPalBearer::CACHE_KEY)) {
|
||||
$this->cache->delete(PayPalBearer::CACHE_KEY);
|
||||
}
|
||||
wp_schedule_single_event(
|
||||
time() - 1,
|
||||
WebhookRegistrar::EVENT_HOOK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue