endpoint_manager = $endpoint;
}
/**
* {@inheritdoc}
*/
public function get_subscribed_events() {
return array(
'__unstable_simpay_before_webhook_setting' => 'output_button',
'wp_ajax_simpay_recreate_webhook' => 'handle_recreate_webhook',
);
}
/**
* Outputs the button to recreate the webhook.
*
* @since 4.14.0
*
* @return void
*/
public function output_button() {
$webhooks_url = simpay_is_test_mode()
? 'https://dashboard.stripe.com/test/workbench/webhooks/'
: 'https://dashboard.stripe.com/workbench/webhooks/';
// Check current webhook status.
$endpoint = $this->endpoint_manager->exists();
$status_message = '';
$status_color = '';
if ( $endpoint instanceof \SimplePay\Vendor\Stripe\WebhookEndpoint ) {
if ( $this->endpoint_manager->is_valid( $endpoint ) ) {
$status_message = __( 'Your Stripe webhook is set up correctly.', 'stripe' );
$status_color = 'green';
} else {
$status_message = __( 'Action required: Your Stripe webhook is not valid. Please recreate it.', 'stripe' );
$status_color = 'red';
}
$action_text = __( 'Recreate Webhook', 'stripe' );
} else {
$status_message = __( 'No Stripe webhook is currently set up.', 'stripe' );
$status_color = 'red';
$action_text = __( 'Create Webhook', 'stripe' );
}
// Output the button.
echo wp_kses_post(
sprintf(
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'Stripe uses webhooks to notify WP Simple Pay when an event has occurred in your Stripe account. Ensure an endpoint is present in the %1$sStripe webhook settings %2$s', 'stripe' ),
'',
'' . Utils\get_external_link_markup() . '
'
)
);
wp_nonce_field( 'simpay_recreate_webhook', 'simpay_recreate_webhook_nonce' );
echo '