<?php
/**
 * WooCommerce Email Classes for Stripe Subscription Manager.
 *
 * Contains the shared base class and all inline email subclasses.
 * This file is loaded ONLY when the `woocommerce_email_classes` filter fires,
 * ensuring WC_Email is available.
 *
 * @see STRP_SUB_WC_Emails::load_email_classes()
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! class_exists( 'WC_Email' ) ) {
    return;
}

// ── Base class ───────────────────────────────────────────────────────────────

/**
 * Shared helper used by all plugin email subclasses.
 *
 * Note: Themes and child themes can override email templates by copying them to
 * `yourtheme/woocommerce/emails/` following the standard WooCommerce template
 * override system. See WC_Email::get_content() for details.
 */
abstract class STRP_SUB_Email_Base extends WC_Email {

    // Note: These emails use inline HTML rendering. For WooCommerce template overrides, see STRP_SUB_WC_Email_Lifetime.

    /** @var WP_User|null The customer user object set by trigger(). */
    protected $customer;

    /** @var array Arbitrary payload data set by trigger(). */
    protected $payload = array();

    /**
     * Return the WooCommerce my-account URL.
     */
    protected function myaccount_url() {
        return function_exists( 'wc_get_page_permalink' )
            ? wc_get_page_permalink( 'myaccount' )
            : home_url( '/' );
    }

    /**
     * Render a styled CTA button for use in get_content_html().
     *
     * @param string $url   Button target URL.
     * @param string $label Button label text.
     * @return string HTML string.
     */
    protected function button( $url, $label ) {
        return '<p style="text-align:center;margin:24px 0;">'
             . '<a href="' . esc_url( $url ) . '" '
             . 'style="background:#4f46e5;color:#ffffff;padding:12px 28px;'
             . 'border-radius:4px;text-decoration:none;display:inline-block;font-weight:600;">'
             . esc_html( $label ) . '</a></p>';
    }

    /**
     * Wrap partial body HTML in a minimal email container.
     *
     * @param string $inner_html Partial HTML (paragraphs, buttons, etc.).
     * @return string Complete HTML email.
     */
    protected function wrap_html( $inner_html ) {
        $site_name = get_bloginfo( 'name' );
        $html  = '<!DOCTYPE html><html><body>';
        $html .= '<div style="font-family:sans-serif;color:#333;max-width:600px;margin:0 auto;padding:24px;">';
        $html .= '<h2 style="border-bottom:2px solid #4f46e5;padding-bottom:8px;">'
               . esc_html( $this->get_heading() ) . '</h2>';
        $html .= wp_kses_post( $inner_html );
        $html .= '<p style="margin-top:32px;font-size:12px;color:#999;">'
               . esc_html( $site_name ) . '</p>';
        $html .= '</div></body></html>';
        return $html;
    }

    /**
     * Send the email to the customer set in $this->customer.
     *
     * @return void
     */
    protected function dispatch() {
        if ( ! $this->customer || ! $this->is_enabled() ) {
            return;
        }

        $this->recipient = $this->customer->user_email;

        $this->send(
            $this->get_recipient(),
            $this->get_subject(),
            $this->get_content(),
            $this->get_headers(),
            $this->get_attachments()
        );
    }

    /**
     * Return the plain-text version of the email (minimal fallback).
     *
     * @return string
     */
    public function get_content_plain() {
        return wp_strip_all_tags( $this->get_content_html() );
    }
}

// ── Email: New Subscription Welcome ─────────────────────────────────────────

class STRP_SUB_Email_Subscription_Welcome extends STRP_SUB_Email_Base {

    public function __construct() {
        $this->id             = 'strp_sub_subscription_welcome';
        $this->customer_email = true;
        $this->title          = __( 'Subscription Welcome', 'subscription-manager-for-stripe' );
        $this->description    = __( 'Sent to customers after they start a new subscription (including trial).', 'subscription-manager-for-stripe' );
        $this->subject        = __( '[{site_title}] Welcome — your subscription is now active', 'subscription-manager-for-stripe' );
        $this->heading        = __( 'Your subscription is active!', 'subscription-manager-for-stripe' );

        parent::__construct();

        add_action( 'strp_sub_send_subscription_welcome_email', array( $this, 'trigger' ), 10, 2 );
    }

    /**
     * Admin settings fields shown in WooCommerce > Settings > Emails.
     */
    public function init_form_fields() {
        $this->form_fields = array(
            'enabled'    => array(
                'title'   => __( 'Enable / Disable', 'subscription-manager-for-stripe' ),
                'type'    => 'checkbox',
                'label'   => __( 'Enable this email notification', 'subscription-manager-for-stripe' ),
                'default' => 'yes',
            ),
            'subject'    => array(
                'title'       => __( 'Subject', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->subject,
                'default'     => '',
            ),
            'heading'    => array(
                'title'       => __( 'Email Heading', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->heading,
                'default'     => '',
            ),
            'email_type' => array(
                'title'   => __( 'Email type', 'subscription-manager-for-stripe' ),
                'type'    => 'select',
                'options' => $this->get_email_type_options(),
                'default' => 'html',
            ),
        );
    }

    /**
     * @param int    $user_id      WordPress user ID.
     * @param object $subscription Stripe Subscription object.
     */
    public function trigger( $user_id, $subscription ) {
        $this->setup_locale();

        $this->customer = get_userdata( $user_id );
        if ( ! $this->customer ) {
            $this->restore_locale();
            return;
        }

        $this->payload = array(
            'subscription' => $subscription,
            'user_id'      => $user_id,
        );

        $this->dispatch();
        $this->restore_locale();
    }

    public function get_content_html() {
        $user         = $this->customer;
        $subscription = $this->payload['subscription'];
        $site_name    = get_bloginfo( 'name' );
        $user_name    = $user->first_name ?: $user->display_name;
        // Stripe subscription status — 'trialing' is a Stripe API billing status, not a plugin trial.
        $is_trial     = ( $subscription->status === 'trialing' );
        $next_billing = date_i18n( get_option( 'date_format' ), $subscription->current_period_end );

        $interval          = isset( $subscription->plan->interval ) ? $subscription->plan->interval : 'month';
        $subscription_type = ( $interval === 'year' )
            ? __( 'Annual', 'subscription-manager-for-stripe' )
            : __( 'Monthly', 'subscription-manager-for-stripe' );

        $body = '<p>' . sprintf(
            /* translators: %s: customer first name or display name */
            __( 'Hello %s,', 'subscription-manager-for-stripe' ), esc_html( $user_name )
        ) . '</p>';

        if ( $is_trial ) {
            $body .= '<p>' . sprintf(
                /* translators: 1: subscription type (Monthly/Annual), 2: site name */
                __( 'Welcome to %2$s! Your %1$s subscription is active with a free trial period.', 'subscription-manager-for-stripe' ),
                esc_html( $subscription_type ),
                esc_html( $site_name )
            ) . '</p>';
            $body .= '<p>' . sprintf(
                /* translators: %s: trial end / first billing date */
                __( 'You have full access to all features. Your first payment will be charged on <strong>%s</strong>.', 'subscription-manager-for-stripe' ),
                esc_html( $next_billing )
            ) . '</p>';
        } else {
            $body .= '<p>' . sprintf(
                /* translators: 1: subscription type (Monthly/Annual), 2: site name */
                __( 'Welcome to %2$s! Your %1$s subscription is now active.', 'subscription-manager-for-stripe' ),
                esc_html( $subscription_type ),
                esc_html( $site_name )
            ) . '</p>';
            $body .= '<p>' . sprintf(
                /* translators: %s: next billing date */
                __( 'You have full access to all features. Your next payment is scheduled for <strong>%s</strong>.', 'subscription-manager-for-stripe' ),
                esc_html( $next_billing )
            ) . '</p>';
        }

        $body .= $this->button( $this->myaccount_url(), __( 'Go to My Account', 'subscription-manager-for-stripe' ) );

        return $this->wrap_html( $body );
    }
}

// ── Email: Renewal ───────────────────────────────────────────────────────────

class STRP_SUB_Email_Renewal extends STRP_SUB_Email_Base {

    public function __construct() {
        $this->id             = 'strp_sub_renewal';
        $this->customer_email = true;
        $this->title          = __( 'Subscription Renewed', 'subscription-manager-for-stripe' );
        $this->description    = __( 'Sent to customers when their subscription renews successfully.', 'subscription-manager-for-stripe' );
        $this->subject        = __( '[{site_title}] Your subscription has been renewed', 'subscription-manager-for-stripe' );
        $this->heading        = __( 'Subscription renewed!', 'subscription-manager-for-stripe' );

        parent::__construct();

        add_action( 'strp_sub_send_renewal_email', array( $this, 'trigger' ), 10, 3 );
    }

    /**
     * Admin settings fields shown in WooCommerce > Settings > Emails.
     */
    public function init_form_fields() {
        $this->form_fields = array(
            'enabled'    => array(
                'title'   => __( 'Enable / Disable', 'subscription-manager-for-stripe' ),
                'type'    => 'checkbox',
                'label'   => __( 'Enable this email notification', 'subscription-manager-for-stripe' ),
                'default' => 'yes',
            ),
            'subject'    => array(
                'title'       => __( 'Subject', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->subject,
                'default'     => '',
            ),
            'heading'    => array(
                'title'       => __( 'Email Heading', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->heading,
                'default'     => '',
            ),
            'email_type' => array(
                'title'   => __( 'Email type', 'subscription-manager-for-stripe' ),
                'type'    => 'select',
                'options' => $this->get_email_type_options(),
                'default' => 'html',
            ),
        );
    }

    /**
     * @param int    $user_id      WordPress user ID.
     * @param object $subscription Stripe Subscription object.
     * @param object $invoice      Stripe Invoice object.
     */
    public function trigger( $user_id, $subscription, $invoice ) {
        $this->setup_locale();

        $this->customer = get_userdata( $user_id );
        if ( ! $this->customer ) {
            $this->restore_locale();
            return;
        }

        $this->payload = array(
            'subscription' => $subscription,
            'invoice'      => $invoice,
            'user_id'      => $user_id,
        );

        $this->dispatch();
        $this->restore_locale();
    }

    public function get_content_html() {
        $user         = $this->customer;
        $subscription = $this->payload['subscription'];
        $invoice      = $this->payload['invoice'];
        $site_name    = get_bloginfo( 'name' );
        $user_name    = $user->first_name ?: $user->display_name;
        $next_billing = date_i18n( get_option( 'date_format' ), $subscription->current_period_end );
        $amount_paid  = number_format( $invoice->amount_paid / 100, 2 );
        $currency     = strtoupper( $invoice->currency );

        $body  = '<p>' . sprintf(
            /* translators: %s: customer first name or display name */
            __( 'Hello %s,', 'subscription-manager-for-stripe' ), esc_html( $user_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: %s: site name */
            __( 'Your %s subscription has been successfully renewed. Thank you for your continued support!', 'subscription-manager-for-stripe' ),
            esc_html( $site_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: 1: currency code, 2: amount, 3: next billing date */
            __( 'Amount charged: <strong>%1$s %2$s</strong>. Your next billing date is <strong>%3$s</strong>.', 'subscription-manager-for-stripe' ),
            esc_html( $currency ),
            esc_html( $amount_paid ),
            esc_html( $next_billing )
        ) . '</p>';
        $body .= $this->button( $this->myaccount_url(), __( 'Go to My Account', 'subscription-manager-for-stripe' ) );

        return $this->wrap_html( $body );
    }
}

// ── Email: Trial Converted ───────────────────────────────────────────────────

class STRP_SUB_Email_Trial_Converted extends STRP_SUB_Email_Base {

    public function __construct() {
        $this->id             = 'strp_sub_trial_converted';
        $this->customer_email = true;
        $this->title          = __( 'Trial Converted to Paid', 'subscription-manager-for-stripe' );
        $this->description    = __( 'Sent when a customer\'s free trial converts to a paid subscription.', 'subscription-manager-for-stripe' );
        $this->subject        = __( '[{site_title}] Your trial has ended — welcome as a paying member!', 'subscription-manager-for-stripe' );
        $this->heading        = __( 'Your trial has ended', 'subscription-manager-for-stripe' );

        parent::__construct();

        add_action( 'strp_sub_send_trial_converted_email', array( $this, 'trigger' ), 10, 3 );
    }

    /**
     * Admin settings fields shown in WooCommerce > Settings > Emails.
     */
    public function init_form_fields() {
        $this->form_fields = array(
            'enabled'    => array(
                'title'   => __( 'Enable / Disable', 'subscription-manager-for-stripe' ),
                'type'    => 'checkbox',
                'label'   => __( 'Enable this email notification', 'subscription-manager-for-stripe' ),
                'default' => 'yes',
            ),
            'subject'    => array(
                'title'       => __( 'Subject', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->subject,
                'default'     => '',
            ),
            'heading'    => array(
                'title'       => __( 'Email Heading', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->heading,
                'default'     => '',
            ),
            'email_type' => array(
                'title'   => __( 'Email type', 'subscription-manager-for-stripe' ),
                'type'    => 'select',
                'options' => $this->get_email_type_options(),
                'default' => 'html',
            ),
        );
    }

    /**
     * @param int         $user_id      WordPress user ID.
     * @param object|null $subscription Stripe Subscription object (may be null when called from invoice.created).
     * @param object      $invoice      Stripe Invoice object.
     */
    public function trigger( $user_id, $subscription, $invoice ) {
        $this->setup_locale();

        $this->customer = get_userdata( $user_id );
        if ( ! $this->customer ) {
            $this->restore_locale();
            return;
        }

        $this->payload = array(
            'subscription' => $subscription,
            'invoice'      => $invoice,
            'user_id'      => $user_id,
        );

        $this->dispatch();
        $this->restore_locale();
    }

    public function get_content_html() {
        $user         = $this->customer;
        $subscription = $this->payload['subscription'];
        $invoice      = $this->payload['invoice'];
        $site_name    = get_bloginfo( 'name' );
        $user_name    = $user->first_name ?: $user->display_name;

        // Amount — prefer amount_paid (post-payment), fall back to amount_due (pre-payment / SEPA)
        $raw_amount  = isset( $invoice->amount_paid ) && $invoice->amount_paid > 0
            ? $invoice->amount_paid
            : $invoice->amount_due;
        $amount      = number_format( $raw_amount / 100, 2 );
        $currency    = strtoupper( $invoice->currency );

        // Next billing — use subscription or invoice line data
        if ( $subscription && isset( $subscription->current_period_end ) ) {
            $next_billing = date_i18n( get_option( 'date_format' ), $subscription->current_period_end );
        } elseif ( isset( $invoice->lines->data[0]->period->end ) ) {
            $next_billing = date_i18n( get_option( 'date_format' ), $invoice->lines->data[0]->period->end );
        } else {
            $next_billing = __( 'soon', 'subscription-manager-for-stripe' );
        }

        $body  = '<p>' . sprintf(
            /* translators: %s: customer first name or display name */
            __( 'Hello %s,', 'subscription-manager-for-stripe' ), esc_html( $user_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: %s: site name */
            __( 'Your free trial of %s has ended and you now have full access to all features!', 'subscription-manager-for-stripe' ),
            esc_html( $site_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: 1: currency code, 2: amount */
            __( 'Amount charged: <strong>%1$s %2$s</strong>.', 'subscription-manager-for-stripe' ),
            esc_html( $currency ),
            esc_html( $amount )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: %s: next billing date */
            __( 'Your next payment is scheduled for <strong>%s</strong>.', 'subscription-manager-for-stripe' ),
            esc_html( $next_billing )
        ) . '</p>';
        $body .= $this->button( $this->myaccount_url(), __( 'Go to My Account', 'subscription-manager-for-stripe' ) );

        return $this->wrap_html( $body );
    }
}

// ── Email: Payment Failed ────────────────────────────────────────────────────

class STRP_SUB_Email_Payment_Failed extends STRP_SUB_Email_Base {

    public function __construct() {
        $this->id             = 'strp_sub_payment_failed';
        $this->customer_email = true;
        $this->title          = __( 'Subscription Payment Failed', 'subscription-manager-for-stripe' );
        $this->description    = __( 'Sent when a subscription renewal payment fails.', 'subscription-manager-for-stripe' );
        $this->subject        = __( '[{site_title}] Payment failed — action required', 'subscription-manager-for-stripe' );
        $this->heading        = __( 'Payment failed — please update your payment method', 'subscription-manager-for-stripe' );

        parent::__construct();

        add_action( 'strp_sub_send_payment_failed_email', array( $this, 'trigger' ), 10, 3 );
    }

    /**
     * Admin settings fields shown in WooCommerce > Settings > Emails.
     */
    public function init_form_fields() {
        $this->form_fields = array(
            'enabled'    => array(
                'title'   => __( 'Enable / Disable', 'subscription-manager-for-stripe' ),
                'type'    => 'checkbox',
                'label'   => __( 'Enable this email notification', 'subscription-manager-for-stripe' ),
                'default' => 'yes',
            ),
            'subject'    => array(
                'title'       => __( 'Subject', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->subject,
                'default'     => '',
            ),
            'heading'    => array(
                'title'       => __( 'Email Heading', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->heading,
                'default'     => '',
            ),
            'email_type' => array(
                'title'   => __( 'Email type', 'subscription-manager-for-stripe' ),
                'type'    => 'select',
                'options' => $this->get_email_type_options(),
                'default' => 'html',
            ),
        );
    }

    /**
     * @param int    $user_id   WordPress user ID.
     * @param object $invoice   Stripe Invoice object.
     * @param object $order     WooCommerce Order object.
     */
    public function trigger( $user_id, $invoice, $order ) {
        $this->setup_locale();

        $this->customer = get_userdata( $user_id );
        if ( ! $this->customer ) {
            $this->restore_locale();
            return;
        }

        // Link to the my-account page where the customer can manage their subscription.
        // We intentionally avoid pre-generating a Billing Portal session URL here because
        // portal sessions expire within minutes and emails may be delivered with delay.
        $portal_url = wc_get_page_permalink( 'myaccount' );

        $this->payload = array(
            'invoice'    => $invoice,
            'order'      => $order,
            'user_id'    => $user_id,
            'portal_url' => $portal_url,
        );

        $this->dispatch();
        $this->restore_locale();
    }

    public function get_content_html() {
        $user       = $this->customer;
        $invoice    = $this->payload['invoice'];
        $user_id    = $this->payload['user_id'];
        $site_name  = get_bloginfo( 'name' );
        $user_name  = $user->first_name ?: $user->display_name;
        $amount_due = number_format( $invoice->amount_due / 100, 2 );
        $currency   = strtoupper( $invoice->currency );

        $next_attempt = null;
        if ( isset( $invoice->next_payment_attempt ) && $invoice->next_payment_attempt ) {
            $next_attempt = date_i18n( get_option( 'date_format' ), $invoice->next_payment_attempt );
        }

        // Use the pre-generated portal URL from trigger() to avoid API calls during rendering
        $portal_url = ! empty( $this->payload['portal_url'] ) ? $this->payload['portal_url'] : $this->myaccount_url();

        $body  = '<p>' . sprintf(
            /* translators: %s: customer first name or display name */
            __( 'Hello %s,', 'subscription-manager-for-stripe' ), esc_html( $user_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: %s: site name */
            __( 'Unfortunately, the automatic renewal payment for your %s subscription has failed. This can happen due to an expired card or insufficient funds.', 'subscription-manager-for-stripe' ),
            esc_html( $site_name )
        ) . '</p>';
        $body .= '<p>' . sprintf(
            /* translators: 1: currency code, 2: amount */
            __( '<strong>Amount due: %1$s %2$s.</strong> Your access has been temporarily suspended until payment is processed.', 'subscription-manager-for-stripe' ),
            esc_html( $currency ),
            esc_html( $amount_due )
        ) . '</p>';

        if ( $next_attempt ) {
            $body .= '<p>' . sprintf(
                /* translators: %s: next retry date */
                __( 'We will automatically retry the payment on <strong>%s</strong>.', 'subscription-manager-for-stripe' ),
                esc_html( $next_attempt )
            ) . '</p>';
        }

        $body .= '<p>' . __( 'To restore access immediately, please update your payment method:', 'subscription-manager-for-stripe' ) . '</p>';
        $body .= $this->button( $portal_url, __( 'Update Payment Method', 'subscription-manager-for-stripe' ) );
        $body .= '<p><small>' . __( 'If you have any questions, please contact our support team.', 'subscription-manager-for-stripe' ) . '</small></p>';

        return $this->wrap_html( $body );
    }
}

// ── Email: Fraud Block ───────────────────────────────────────────────────────

class STRP_SUB_Email_Fraud_Block extends STRP_SUB_Email_Base {

    public function __construct() {
        $this->id             = 'strp_sub_fraud_block';
        $this->customer_email = true;
        $this->title          = __( 'Subscription Not Activated (Fraud Block)', 'subscription-manager-for-stripe' );
        $this->description    = __( 'Sent when a subscription is blocked due to duplicate payment method detection.', 'subscription-manager-for-stripe' );
        $this->subject        = __( '[{site_title}] Subscription not activated — please contact support', 'subscription-manager-for-stripe' );
        $this->heading        = __( 'Subscription not activated', 'subscription-manager-for-stripe' );

        parent::__construct();

        add_action( 'strp_sub_send_fraud_block_email', array( $this, 'trigger' ), 10, 1 );
    }

    /**
     * Admin settings fields shown in WooCommerce > Settings > Emails.
     */
    public function init_form_fields() {
        $this->form_fields = array(
            'enabled'    => array(
                'title'   => __( 'Enable / Disable', 'subscription-manager-for-stripe' ),
                'type'    => 'checkbox',
                'label'   => __( 'Enable this email notification', 'subscription-manager-for-stripe' ),
                'default' => 'yes',
            ),
            'subject'    => array(
                'title'       => __( 'Subject', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->subject,
                'default'     => '',
            ),
            'heading'    => array(
                'title'       => __( 'Email Heading', 'subscription-manager-for-stripe' ),
                'type'        => 'text',
                'placeholder' => $this->heading,
                'default'     => '',
            ),
            'email_type' => array(
                'title'   => __( 'Email type', 'subscription-manager-for-stripe' ),
                'type'    => 'select',
                'options' => $this->get_email_type_options(),
                'default' => 'html',
            ),
        );
    }

    /**
     * @param int $user_id WordPress user ID.
     */
    public function trigger( $user_id ) {
        $this->setup_locale();

        $this->customer = get_userdata( $user_id );
        if ( ! $this->customer ) {
            $this->restore_locale();
            return;
        }

        $this->payload = array( 'user_id' => $user_id );

        $this->dispatch();
        $this->restore_locale();
    }

    public function get_content_html() {
        $user      = $this->customer;
        $user_name = $user->first_name ?: $user->display_name;

        $body  = '<p>' . sprintf(
            /* translators: %s: customer first name or display name */
            __( 'Hello %s,', 'subscription-manager-for-stripe' ), esc_html( $user_name )
        ) . '</p>';
        $body .= '<p>' . __( 'Your subscription could not be activated.', 'subscription-manager-for-stripe' ) . '</p>';
        $body .= '<p>' . __( 'Our systems detected that the payment method used was previously associated with a free trial. Each payment method may only be used for one trial period.', 'subscription-manager-for-stripe' ) . '</p>';
        $body .= '<p>' . __( 'You have not been charged.', 'subscription-manager-for-stripe' ) . '</p>';
        $body .= '<p>' . __( 'If you believe this is an error (for example, a shared card within a family or business), please contact our support team and we will be happy to resolve this for you.', 'subscription-manager-for-stripe' ) . '</p>';
        $body .= $this->button( home_url( '/' ), __( 'Contact Support', 'subscription-manager-for-stripe' ) );

        return $this->wrap_html( $body );
    }
}
