| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> |
| 2 |
<?php |
| 3 |
/** |
| 4 |
* @var \FluentCart\App\Models\Order $order |
| 5 |
* @var \FluentCart\App\Models\Subscription $subscription |
| 6 |
* @var string $error Gateway failure reason |
| 7 |
* @var string|null $next_retry_at GMT datetime of the next automatic retry, if any |
| 8 |
*/ |
| 9 |
|
| 10 |
$paymentMethodText = $subscription->getPaymentMethodText(); |
| 11 |
$nextRetryAt = isset($next_retry_at) ? $next_retry_at : null; |
| 12 |
$formattedRetryDate = \FluentCart\App\Services\DateTime\DateFormatter::format($nextRetryAt, false, $order); |
| 13 |
// getCustomerDashboardUrl() returns a broken relative path ("/subscription/{uuid}") |
| 14 |
// when no customer profile page is configured — only render the CTA when the |
| 15 |
// dashboard base actually exists. |
| 16 |
$updateMethodUrl = (new \FluentCart\Api\StoreSettings())->getCustomerProfilePage() |
| 17 |
? \FluentCart\App\Services\URL::getCustomerDashboardUrl('subscription/' . $subscription->uuid) |
| 18 |
: ''; |
| 19 |
// Admin preview renders this template with stand-in objects, not persisted |
| 20 |
// models — isExhausted() type-hints Order, so gate the call on a real model. |
| 21 |
$payNowAllowed = ($order instanceof \FluentCart\App\Models\Order) |
| 22 |
&& \FluentCart\App\Modules\Subscriptions\Services\SystemChargeService::isExhausted($subscription, $order); |
| 23 |
?> |
| 24 |
|
| 25 |
<div class="space_bottom_30"> |
| 26 |
<p> |
| 27 |
<?php |
| 28 |
printf( |
| 29 |
/* translators: %1$s is the customer's full name */ |
| 30 |
esc_html__( 'Hello %1$s,', 'fluent-cart' ), |
| 31 |
esc_html($order->customer->full_name) |
| 32 |
); |
| 33 |
?> |
| 34 |
</p> |
| 35 |
|
| 36 |
<p> |
| 37 |
<?php |
| 38 |
if ($paymentMethodText) { |
| 39 |
printf( |
| 40 |
/* translators: %1$s is the subscription item name, %2$s is the saved payment method (e.g. visa ***4242) */ |
| 41 |
esc_html__( 'We were unable to charge your saved payment method (%2$s) for the renewal of %1$s.', 'fluent-cart' ), |
| 42 |
esc_html( $subscription->item_name ), |
| 43 |
esc_html( $paymentMethodText ) |
| 44 |
); |
| 45 |
} else { |
| 46 |
printf( |
| 47 |
/* translators: %1$s is the subscription item name */ |
| 48 |
esc_html__( 'We were unable to charge your saved payment method for the renewal of %1$s.', 'fluent-cart' ), |
| 49 |
esc_html( $subscription->item_name ) |
| 50 |
); |
| 51 |
} |
| 52 |
?> |
| 53 |
</p> |
| 54 |
|
| 55 |
<?php if (!empty($error)): ?> |
| 56 |
<p> |
| 57 |
<?php |
| 58 |
printf( |
| 59 |
/* translators: %1$s is the payment failure reason reported by the payment provider */ |
| 60 |
esc_html__( 'Reason: %1$s', 'fluent-cart' ), |
| 61 |
'<em>' . esc_html( $error ) . '</em>' |
| 62 |
); |
| 63 |
?> |
| 64 |
</p> |
| 65 |
<?php endif; ?> |
| 66 |
|
| 67 |
<p> |
| 68 |
<?php |
| 69 |
if ($payNowAllowed) { |
| 70 |
if ($formattedRetryDate) { |
| 71 |
if ($updateMethodUrl) { |
| 72 |
printf( |
| 73 |
/* translators: %1$s is the date of the next automatic charge attempt */ |
| 74 |
esc_html__( 'We will automatically try again on %1$s. To avoid any interruption, you can pay now or update your payment method from your account.', 'fluent-cart' ), |
| 75 |
'<strong>' . esc_html( $formattedRetryDate ) . '</strong>' |
| 76 |
); |
| 77 |
} else { |
| 78 |
printf( |
| 79 |
/* translators: %1$s is the date of the next automatic charge attempt */ |
| 80 |
esc_html__( 'We will automatically try again on %1$s. To avoid any interruption, you can pay now.', 'fluent-cart' ), |
| 81 |
'<strong>' . esc_html( $formattedRetryDate ) . '</strong>' |
| 82 |
); |
| 83 |
} |
| 84 |
} elseif ($updateMethodUrl) { |
| 85 |
esc_html_e( 'Please pay now or update your payment method from your account to keep your subscription active.', 'fluent-cart' ); |
| 86 |
} else { |
| 87 |
esc_html_e( 'Please pay now to keep your subscription active.', 'fluent-cart' ); |
| 88 |
} |
| 89 |
} elseif ($formattedRetryDate) { |
| 90 |
if ($updateMethodUrl) { |
| 91 |
printf( |
| 92 |
/* translators: %1$s is the date of the next automatic charge attempt */ |
| 93 |
esc_html__( 'We will automatically try again on %1$s. You can update your payment method from your account if it has changed.', 'fluent-cart' ), |
| 94 |
'<strong>' . esc_html( $formattedRetryDate ) . '</strong>' |
| 95 |
); |
| 96 |
} else { |
| 97 |
printf( |
| 98 |
/* translators: %1$s is the date of the next automatic charge attempt */ |
| 99 |
esc_html__( 'We will automatically try again on %1$s.', 'fluent-cart' ), |
| 100 |
'<strong>' . esc_html( $formattedRetryDate ) . '</strong>' |
| 101 |
); |
| 102 |
} |
| 103 |
} elseif ($updateMethodUrl) { |
| 104 |
esc_html_e( 'We will automatically try again shortly. You can update your payment method from your account if it has changed.', 'fluent-cart' ); |
| 105 |
} else { |
| 106 |
esc_html_e( 'We will automatically try again shortly.', 'fluent-cart' ); |
| 107 |
} |
| 108 |
?> |
| 109 |
</p> |
| 110 |
</div> |
| 111 |
|
| 112 |
<?php |
| 113 |
|
| 114 |
\FluentCart\App\App::make('view')->render('emails.parts.items_table', [ |
| 115 |
'order' => $order, |
| 116 |
'formattedItems' => $order->order_items, |
| 117 |
'heading' => __('Renewal Summary', 'fluent-cart'), |
| 118 |
]); |
| 119 |
|
| 120 |
echo '<hr />'; |
| 121 |
|
| 122 |
if ($payNowAllowed) { |
| 123 |
\FluentCart\App\App::make('view')->render('emails.parts.call_to_action_box', [ |
| 124 |
'content' => esc_html__( 'Pay this renewal order now to keep your subscription active — no waiting for the retry.', 'fluent-cart' ), |
| 125 |
'link' => \FluentCart\App\Services\Payments\PaymentHelper::getCustomPaymentLink($order->uuid), |
| 126 |
'button_text' => __('Pay Now', 'fluent-cart'), |
| 127 |
]); |
| 128 |
} |
| 129 |
|
| 130 |
if ($updateMethodUrl) : |
| 131 |
?> |
| 132 |
<p> |
| 133 |
<?php |
| 134 |
printf( |
| 135 |
/* translators: %1$s is an HTML link to the customer's subscription page */ |
| 136 |
esc_html__( 'Card expired or changed? %1$s to replace the payment method we charge automatically.', 'fluent-cart' ), |
| 137 |
'<a href="' . esc_url( $updateMethodUrl ) . '">' . esc_html__( 'Update your payment method', 'fluent-cart' ) . '</a>' |
| 138 |
); |
| 139 |
?> |
| 140 |
</p> |
| 141 |
<?php |
| 142 |
endif; |
| 143 |
|