], Helpers::get_auth_opts() ); } catch ( Exception $e ) { return false; } return $webhook; } /** * Get list of all webhook endpoints. * * @since 1.8.4 * * @return array */ private function get_all(): array { try { $webhooks = WebhookEndpoint::all( [], Helpers::get_auth_opts() ); } catch ( Exception $e ) { return []; } return isset( $webhooks->data ) ? (array) $webhooks->data : []; } /** * Save webhook settings. * * @since 1.8.4 * * @param WebhookEndpoint $webhook Webhook endpoint. */ private function save_settings( $webhook ) { $mode = Helpers::get_stripe_mode(); $settings = (array) get_option( 'wpforms_settings', [] ); // Save webhooks endpoint ID. $settings[ 'stripe-webhooks-id-' . $mode ] = sanitize_text_field( $webhook->id ); // Store webhooks endpoint secret, but it is not defined on ::update() call. if ( ! empty( $webhook->secret ) ) { $settings[ 'stripe-webhooks-secret-' . $mode ] = sanitize_text_field( $webhook->secret ); WebhooksHealthCheck::save_status( WebhooksHealthCheck::SIGNATURE_OPTION, WebhooksHealthCheck::STATUS_OK ); } WebhooksHealthCheck::save_status( WebhooksHealthCheck::ENDPOINT_OPTION, WebhooksHealthCheck::STATUS_OK ); // Enable webhooks setting shouldn't be rewritten. if ( ! isset( $settings['stripe-webhooks-enabled'] ) ) { $settings['stripe-webhooks-enabled'] = true; } update_option( 'wpforms_settings', $settings ); } }