{**
 * Copyright 2024-2025 Simply.IN Sp. z o.o.
 *
 * NOTICE OF LICENSE
 *
 * Licensed under the EUPL-1.2 or later.
 * You may not use this work except in compliance with the Licence.
 *
 * Copy of the Licence is available at:
 * https://joinup.ec.europa.eu/software/page/eupl
 * It is bundled with this package in the file LICENSE.txt
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Licence is distributed on an as is basis,
 * without warranties or conditions of any kind, either express or implied.
 * Check the Licence for the specific language governing permissions
 * and limitations under the License.
 *
 * @author    Simply.IN Sp. z o.o.
 * @copyright 2024-2025 Simply.IN Sp. z o.o.
 * @license   https://joinup.ec.europa.eu/software/page/eupl
 *}
{if $payment_info}
	<div id="simplyin-blik-status-modal" data-is-card-payment="false" class="simplyin-blik-modal simplyin-blik-success">
		<div class="simplyin-blik-content"{if !empty($accent_color)} style="border-color: {$accent_color|escape:'html':'UTF-8'};"{/if}>
			<div class="simplyin-blik-header">
				<h3 class="simplyin-blik-title">{l s='Payment processing by' mod='simplyin'}</h3>
				<div class="simplyin-status-logo">
					{if !empty($payment_info->provider_logo)}

						<img
							style="max-height:20px;"
							decoding="async"
							class="simplyin"
							src="{$payment_info->provider_logo|escape:'html':'UTF-8'}"
							alt="{$payment_info->payment_provider|escape:'html':'UTF-8'}"
						>
					{else}
						<img
							decoding="async"
							class="simplyin"
						{if $payment_info->payment_provider == 'payu'}
							src="{$module_path|escape:'html':'UTF-8'}views/img/payu_simplyin.svg"
							alt="PayU"
						{else if $payment_info->payment_provider == 'paynow'}
							src="{$module_path|escape:'html':'UTF-8'}views/img/paynow_simplyin.png"
							alt="PayNow"
						{else}
							src="{$module_path|escape:'html':'UTF-8'}views/img/simplyin_app_logo.svg"
							alt="SimplyIn"
						{/if}
						>
					{/if}
				</div>
			</div>
			{* One heading, one explanation, one call to action for a failed payment: the pay-again
			   surface's own decision-driven copy IS that single message here, embedded rather than
			   standing next to a second, static one repeating the same fact. Falls back to a plain
			   statement only when the retry surface itself has nothing to add (order not ours,
			   already settled, or closed) - never a state a poll-detected failure reaches.

			   Captured once rather than repeated per payment type below: the markup does not depend
			   on $payment_info->type, only on $retry_html/$payment status. *}
			{capture name="status_error_block"}
	        <div class="simplyin-blik-status-container" id="status-error" >
	            {if $retry_html}
	                {* The retry surface's own copy already states the failure and the reason - the
	                   icon that used to sit beside the static fallback below has nothing of its own
	                   to pair with here, so it is not repeated: one message, not a message plus an
	                   orphaned glyph. *}
	                <div class="simplyin-blik-status-text">
	                    {$retry_html nofilter}
	                </div>
	            {else}
	                <div class="simplyin-blik-icon">
	                    <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
	                        <path d="M12 2C6.48 2 2 6.48
	                                 2 12s4.48 10 10 10
	                                 10-4.48 10-10S17.52 2
	                                 12 2zM13 13h-2v-6h2v6zm0
	                                 4h-2v-2h2v2z" fill="#ef4444"/>
	                    </svg>
	                </div>
	                <div class="simplyin-blik-status-text">
	                    <div class="simplyin-blik-main-message">
	                        {l s='Payment failed' mod='simplyin'}
	                    </div>
	                    {* One reason per value this plugin has safe, non-fraud shopper copy for -
	                       kept in step with core.js's REJECT_REASON_MESSAGES, which shows the same
	                       four for the live poll without a reload. Every other reason, recognized by
	                       SIN.CORE or not, falls through to the generic sentence. *}
	                    <div class="simplyin-blik-sub-message" id="simplyin-status-error-message">
	                        {if $payment_info->reject_reason == 'BLIK_INVALID_CODE'}
	                            {l s='The BLIK code you entered was incorrect.' mod='simplyin'}
	                        {elseif $payment_info->reject_reason == 'CARD_THREE_DS_FAILED'}
	                            {l s='Your bank did not confirm the card.' mod='simplyin'}
	                        {elseif $payment_info->reject_reason == 'AMOUNT_LIMIT_EXCEEDED'}
	                            {l s='This payment exceeds an allowed transaction limit.' mod='simplyin'}
	                        {elseif $payment_info->reject_reason == 'TRANSACTION_TIMEOUT'}
	                            {l s='The payment took too long and timed out.' mod='simplyin'}
	                        {else}
	                            {l s='This order has not been paid.' mod='simplyin'}
	                        {/if}
	                    </div>
	                </div>
	            {/if}
	        </div>
			{/capture}
			{if $payment_info->type == 'blik'}
			<div class="simplyin-blik-payment-method">
				<div class="simplyin-blik-method-info">
					<input type="radio" id="blik-method" name="payment-method" checked="">
					<label for="blik-method" class="simplyin-blik-label">
						{if !empty($payment_info->logo)}
							<img style="max-height:30px;" decoding="async" src="{$payment_info->logo|escape:'html':'UTF-8'}" alt="BLIK" class="simplyin-blik-logo">
						{else}
							<img style="max-height:30px;" decoding="async" src="{$module_path|escape:'html':'UTF-8'}views/img/blik.svg" alt="BLIK" class="simplyin-blik-logo">
						{/if}
						<span class="simplyin-blik-text"></span>
					</label>
					<span class="simplyin-blik-checkmark">✓</span>
				</div>
			</div>

			<div class="simplyin-blik-status-container" id="status-pending">
		 		<div class="simplyin-blik-icon">
		            <div class="simplyin-blik-loader" id="blik-loader">
						<div class="simplyin-blik-spinner"></div>
					</div>
				</div>
	            <div class="simplyin-blik-status-text">
	                {* The live poll (core.js, setupOrderStatusCheck) writes into this element by id
	                   once it learns whether the attempt is PENDING or AWAITING_CONFIRMATION -
	                   never on elapsed time. Static text here is only what shows before the first
	                   poll tick resolves it. *}
	                <div class="simplyin-blik-sub-message" id="blik-status-message">
	                    {l s='Waiting for confirmation...' mod='simplyin'}
	                </div>
	            </div>
	            <hr/>
	        </div>
			<div class="simplyin-blik-status-container" id="status-success" {if $payment_status == 'PAID'} style="display: flex;"{/if}>
				<div class="simplyin-blik-icon">
					<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="#4CAF50"></path></svg>
				</div>
				<div class="simplyin-blik-status-text">
					<div class="simplyin-blik-main-message">{l s='Payment successful' mod='simplyin'}!</div>
					<div class="simplyin-blik-sub-message">{l s='Payment completed successfully!' mod='simplyin'}</div>
				</div>
			</div>

	        {$smarty.capture.status_error_block nofilter}
			{else if $payment_info->type == 'card' ||$payment_info->type == 'add-card'}
			<div class="simplyin-blik-payment-method">
				<div class="simplyin-blik-method-info">
					<input type="radio" id="blik-method" name="payment-method" checked="">
					<label for="blik-method" class="simplyin-blik-label">
						{if !empty($payment_info->logo)}
							<img style="max-height:30px;" decoding="async" src="{$payment_info->logo|escape:'html':'UTF-8'}" alt="BLIK" class="simplyin-blik-logo">
						{else if $payment_info->card_provider == 'visa'}
							<img style="max-height:30px;" decoding="async" src="{$module_path|escape:'html':'UTF-8'}views/img/visa.svg" alt="BLIK" class="simplyin-blik-logo">
						{else $payment_info->card_provider == 'mastercard'}
							<img style="max-height:30px;" decoding="async" src="{$module_path|escape:'html':'UTF-8'}views/img/mastercard.svg" alt="BLIK" class="simplyin-blik-logo">
						{/if}
						<span class="simplyin-blik-text">{l s='Card' mod='simplyin'}</span>
					</label>
					<span class="simplyin-blik-checkmark">✓</span>
				</div>
			</div>

			<div class="simplyin-blik-status-container" id="status-pending">
		 		<div class="simplyin-blik-icon">
		            <div class="simplyin-blik-loader" id="blik-loader">
						<div class="simplyin-blik-spinner"></div>
					</div>
				</div>
	            <div class="simplyin-blik-status-text">
	                {* The live poll (core.js, setupOrderStatusCheck) writes into this element by id
	                   once it learns whether the attempt is PENDING or AWAITING_CONFIRMATION -
	                   never on elapsed time. Static text here is only what shows before the first
	                   poll tick resolves it. *}
	                <div class="simplyin-blik-sub-message" id="blik-status-message">
	                    {l s='Waiting for confirmation...' mod='simplyin'}
	                </div>
	            </div>
	            <hr/>
	        </div>

			<div class="simplyin-blik-status-container" id="status-success" {if $payment_status == 'PAID'} style="display: flex;"{/if}>
				<div class="simplyin-blik-icon">
					<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="#4CAF50"></path></svg>
				</div>
				<div class="simplyin-blik-status-text">
					<div class="simplyin-blik-main-message">{l s='Payment successful' mod='simplyin'}!</div>
					<div class="simplyin-blik-sub-message">{l s='Payment completed successfully!' mod='simplyin'}</div>
				</div>
			</div>

	        {$smarty.capture.status_error_block nofilter}
			{/if}
		</div>
	</div>
	{literal}

	{/literal}
{/if}
