Get signup links without reloading the page (WIP)

This commit is contained in:
dinamiko 2022-05-27 14:53:55 +02:00
parent aa156a17b2
commit f1e54ced4f
5 changed files with 102 additions and 18 deletions

View file

@ -220,7 +220,18 @@ return array(
$bearer = $container->get( 'api.bearer' );
$page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' );
$signup_link_cache = $container->get( 'onboarding.signup-link-cache' );
return new SettingsListener( $settings, $fields, $webhook_registrar, $cache, $state, $bearer, $page_id, $signup_link_cache );
$signup_link_ids = $container->get( 'onboarding.signup-link-ids' );
return new SettingsListener(
$settings,
$fields,
$webhook_registrar,
$cache,
$state,
$bearer,
$page_id,
$signup_link_cache,
$signup_link_ids
);
},
'wcgateway.order-processor' => static function ( ContainerInterface $container ): OrderProcessor {

View file

@ -88,6 +88,13 @@ class SettingsListener {
*/
protected $signup_link_cache;
/**
* Signup link ids
*
* @var array
*/
protected $signup_link_ids;
/**
* SettingsListener constructor.
*
@ -99,6 +106,7 @@ class SettingsListener {
* @param Bearer $bearer The bearer.
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
* @param Cache $signup_link_cache The signup link cache.
* @param array $signup_link_ids Signup link ids.
*/
public function __construct(
Settings $settings,
@ -108,7 +116,8 @@ class SettingsListener {
State $state,
Bearer $bearer,
string $page_id,
Cache $signup_link_cache
Cache $signup_link_cache,
array $signup_link_ids
) {
$this->settings = $settings;
@ -119,6 +128,7 @@ class SettingsListener {
$this->bearer = $bearer;
$this->page_id = $page_id;
$this->signup_link_cache = $signup_link_cache;
$this->signup_link_ids = $signup_link_ids;
}
/**
@ -271,13 +281,7 @@ class SettingsListener {
) ) {
$this->webhook_registrar->unregister();
$keys = array(
'production-ppcp',
'production-express-checkout',
'sandbox-ppcp',
'sandbox-express-checkout',
);
foreach ( $keys as $key ) {
foreach ( $this->signup_link_ids as $key ) {
if ( $this->signup_link_cache->has( $key ) ) {
$this->signup_link_cache->delete( $key );
}