mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
register webhooks when client_id is added manually
This commit is contained in:
parent
47e5d96f4f
commit
13ef5e8f60
1 changed files with 20 additions and 0 deletions
|
@ -72,6 +72,8 @@ class SettingsListener
|
||||||
$settings['dcc_gateway_enabled'] = isset($_POST['woocommerce_ppcp-credit-card-gateway_enabled'])
|
$settings['dcc_gateway_enabled'] = isset($_POST['woocommerce_ppcp-credit-card-gateway_enabled'])
|
||||||
&& absint($_POST['woocommerce_ppcp-credit-card-gateway_enabled']) === 1;
|
&& absint($_POST['woocommerce_ppcp-credit-card-gateway_enabled']) === 1;
|
||||||
}
|
}
|
||||||
|
$this->maybeRegisterWebhooks($settings);
|
||||||
|
|
||||||
foreach ($settings as $id => $value) {
|
foreach ($settings as $id => $value) {
|
||||||
$this->settings->set($id, $value);
|
$this->settings->set($id, $value);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,24 @@ class SettingsListener
|
||||||
//phpcs:enable WordPress.Security.NonceVerification.Missing
|
//phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function maybeRegisterWebhooks(array $settings)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (! $this->settings->has('client_id') && $settings['client_id']) {
|
||||||
|
$this->webhookRegistrar->register();
|
||||||
|
}
|
||||||
|
if ($this->settings->has('client_id')) {
|
||||||
|
$currentSecret = $this->settings->has('client_secret') ? $this->settings->get('client_secret') : '';
|
||||||
|
if (
|
||||||
|
$settings['client_id'] !== $this->settings->get('client_id')
|
||||||
|
|| $settings['client_secret'] !== $currentSecret
|
||||||
|
) {
|
||||||
|
$this->webhookRegistrar->unregister();
|
||||||
|
$this->webhookRegistrar->register();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//phpcs:disable Inpsyde.CodeQuality.NestingLevel.MaxExceeded
|
//phpcs:disable Inpsyde.CodeQuality.NestingLevel.MaxExceeded
|
||||||
//phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
//phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||||
//phpcs:disable Inpsyde.CodeQuality.FunctionLength.TooLong
|
//phpcs:disable Inpsyde.CodeQuality.FunctionLength.TooLong
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue