|
| 1 | +<style> |
| 2 | + .payfs.fob-container { |
| 3 | + margin-top: 2rem; |
| 4 | + } |
| 5 | +
|
| 6 | + .payfs .fob-qr-code { |
| 7 | + text-align: center; |
| 8 | + margin-bottom: 40px; |
| 9 | + } |
| 10 | +
|
| 11 | + .payfs .fob-qr-code img { |
| 12 | + width: 250px; |
| 13 | + height: auto; |
| 14 | + margin: 0; |
| 15 | + padding: 0; |
| 16 | + } |
| 17 | +
|
| 18 | + .payfs .fob-qr-code figcaption { |
| 19 | + margin-top: 10px; |
| 20 | + font-size: 14px; |
| 21 | + color: #666; |
| 22 | + } |
| 23 | +
|
| 24 | + .payfs .fob-qr-intro { |
| 25 | + margin-bottom: 10px; |
| 26 | + font-size: 16px; |
| 27 | + } |
| 28 | +
|
| 29 | + .payfs .transaction-status-done { |
| 30 | + background-color: var(--bs-tertiary-bg); |
| 31 | + border: none; |
| 32 | + color: var(--primary-color); |
| 33 | + } |
| 34 | +
|
| 35 | + .payfs .transaction-status-done .icon { |
| 36 | + width: 40px; |
| 37 | + height: 40px; |
| 38 | + } |
| 39 | +</style> |
| 40 | + |
| 41 | +<div id="fob-payfs-bank" class="payfs fob-container"> |
| 42 | + @if ($payment->status != \Botble\Payment\Enums\PaymentStatusEnum::COMPLETED) |
| 43 | + <div id="payfs-bank-info"> |
| 44 | + <div class="fob-qr-intro"> |
| 45 | + Cách 1: Mở app ngân hàng/ Ví để <strong>quét mã QR</strong> |
| 46 | + </div> |
| 47 | + <div class="fob-qr-code"> |
| 48 | + <figure> |
| 49 | + <img src="{{ $imageUrl }}" alt="QR Code"> |
| 50 | + </figure> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div class="fob-qr-intro"> |
| 54 | + Cách 2: Chuyển khoản <strong>thủ công</strong> theo thông tin |
| 55 | + </div> |
| 56 | + <div class="fob-qr-information"> |
| 57 | + <table class="table table-hover table-striped"> |
| 58 | + <tr> |
| 59 | + <td>Tên Ngân Hàng</td> |
| 60 | + <td> |
| 61 | + <strong>{{ $bank }}</strong> |
| 62 | + </td> |
| 63 | + <td></td> |
| 64 | + </tr> |
| 65 | + <tr> |
| 66 | + <td>Chủ Tài Khoản</td> |
| 67 | + <td> |
| 68 | + <strong>{{ $bankAccountHolder }}</strong> |
| 69 | + </td> |
| 70 | + <td></td> |
| 71 | + </tr> |
| 72 | + <tr> |
| 73 | + <td>Số Tài Khoản</td> |
| 74 | + <td> |
| 75 | + <strong>{{ $bankAccountNumber }}</strong> |
| 76 | + </td> |
| 77 | + <td class="text-end" style="width: 80px;"> |
| 78 | + <a href="javascript:void(0);" rel="nooper" class="ms-2" type="button" data-clipboard="{{ $bankAccountNumber }}" data-bb-toggle="copy"> |
| 79 | + <x-core::icon name="ti ti-clipboard" /> |
| 80 | + </a> |
| 81 | + </td> |
| 82 | + </tr> |
| 83 | + <tr> |
| 84 | + <td>Nội Dung Chuyển Khoản</td> |
| 85 | + <td> |
| 86 | + <strong>{{ $chargeId }}</strong> |
| 87 | + </td> |
| 88 | + <td class="text-end" style="width: 80px;"> |
| 89 | + <a href="javascript:void(0);" rel="nooper" class="ms-2" type="button" data-clipboard="{{ $chargeId }}" data-bb-toggle="copy"> |
| 90 | + <x-core::icon name="ti ti-clipboard" /> |
| 91 | + </a> |
| 92 | + </td> |
| 93 | + </tr> |
| 94 | + |
| 95 | + <tr> |
| 96 | + <td>Số Tiền Giao Dịch</td> |
| 97 | + <td> |
| 98 | + <strong>{{ $formattedOrderAmount = number_format($orderAmount, 0, ',', '.') . ' ₫' }}</strong> |
| 99 | + @if (isset($originalCurrency) && $originalCurrency !== 'VND') |
| 100 | + <br> |
| 101 | + <small class="text-muted">(≈ {{ number_format($originalAmount, 2) }} {{ $originalCurrency }})</small> |
| 102 | + @endif |
| 103 | + </td> |
| 104 | + <td class="text-end" style="width: 80px;"> |
| 105 | + <a href="javascript:void(0);" rel="nooper" class="ms-2" type="button" data-clipboard="{{ $orderAmount }}" data-bb-toggle="copy"> |
| 106 | + <x-core::icon name="ti ti-clipboard" /> |
| 107 | + </a> |
| 108 | + </td> |
| 109 | + </tr> |
| 110 | + </table> |
| 111 | + |
| 112 | + <div class="alert alert-warning"> |
| 113 | + <p>Vui lòng giữ nguyên nội dung chuyển khoản <strong class="text-danger">{{ $chargeId }}</strong> và nhập đúng số tiền <strong class="text-danger">{{ $formattedOrderAmount }}</strong> để được xác nhận thanh toán trực tuyến.</p> |
| 114 | + @if (isset($originalCurrency) && $originalCurrency !== 'VND') |
| 115 | + <p class="mt-2 mb-0"><em>Số tiền đã được quy đổi từ {{ $originalCurrency }} sang VND theo tỷ giá hiện tại.</em></p> |
| 116 | + @endif |
| 117 | + </div> |
| 118 | + |
| 119 | + <div class="transaction-status text-center" data-bb-toggle="payfs-transaction-status" data-url="{{ route('payfs.transactions.check') }}" data-charge-id="{{ $chargeId }}"> |
| 120 | + Trạng thái chờ thanh toán <img src="{{ url('vendor/core/plugins/fob-payfs/images/loading.gif') }}" width="20" height="20" alt="Loading"> |
| 121 | + </div> |
| 122 | + </div> |
| 123 | + </div> |
| 124 | + @endif |
| 125 | + |
| 126 | + <div @style(['display: none' => $payment->status != \Botble\Payment\Enums\PaymentStatusEnum::COMPLETED]) |
| 127 | + id="payfs-transaction-status-done"> |
| 128 | + <div class="transaction-status-done card text-center pb-3 pt-2"> |
| 129 | + <div class="p-4"> |
| 130 | + <div class="mb-2"> |
| 131 | + <x-core::icon name="ti ti-circle-check"/> |
| 132 | + </div> |
| 133 | + <h4>Thanh toán thành công</h4> |
| 134 | + </div> |
| 135 | + </div> |
| 136 | + </div> |
| 137 | +</div> |
| 138 | + |
| 139 | +<script> |
| 140 | + document.addEventListener('DOMContentLoaded', function () { |
| 141 | + const copyButtons = document.querySelectorAll('[data-bb-toggle="copy"]'); |
| 142 | +
|
| 143 | + copyButtons.forEach((button) => { |
| 144 | + button.addEventListener('click', function (event) { |
| 145 | + event.preventDefault(); |
| 146 | + event.stopPropagation(); |
| 147 | + const textToCopy = this.getAttribute('data-clipboard'); |
| 148 | + fobCopyToClipboard(textToCopy); |
| 149 | + }) |
| 150 | + }) |
| 151 | +
|
| 152 | + }) |
| 153 | +
|
| 154 | + let interval = null |
| 155 | +
|
| 156 | + $(document).ready(function() { |
| 157 | + const paymentStatus = $('[data-bb-toggle="payfs-transaction-status"]') |
| 158 | +
|
| 159 | + if (paymentStatus.length) { |
| 160 | + interval = setInterval(() => fetchPaymentStatus(paymentStatus), 3000) |
| 161 | + } |
| 162 | + }) |
| 163 | +
|
| 164 | + function fetchPaymentStatus(elm) { |
| 165 | + $.ajax({ |
| 166 | + url: elm.data('url'), |
| 167 | + method: 'POST', |
| 168 | + data: { |
| 169 | + charge_id: elm.data('charge-id') |
| 170 | + }, |
| 171 | + success: ({ data }) => { |
| 172 | + if (data.status.value === 'completed') { |
| 173 | + $('#payfs-transaction-status-done').show() |
| 174 | + $('#payfs-bank-info').remove() |
| 175 | +
|
| 176 | + let paymentStatusElement = $(document).find('span[data-bb-target="ecommerce-order-payment-status"]'); |
| 177 | +
|
| 178 | + if (paymentStatusElement.length && data.status_html) { |
| 179 | + paymentStatusElement.html(data.status_html); |
| 180 | + } |
| 181 | +
|
| 182 | + clearInterval(interval) |
| 183 | + } |
| 184 | + } |
| 185 | + }) |
| 186 | + } |
| 187 | +
|
| 188 | + async function fobCopyToClipboard(textToCopy) { |
| 189 | + if (navigator.clipboard && window.isSecureContext) { |
| 190 | + await navigator.clipboard.writeText(textToCopy); |
| 191 | + } else { |
| 192 | + fobUnsecuredCopyToClipboard(textToCopy); |
| 193 | + } |
| 194 | +
|
| 195 | + MainCheckout.showSuccess('Sao chép thành công!'); |
| 196 | + } |
| 197 | +
|
| 198 | + function fobUnsecuredCopyToClipboard(textToCopy) { |
| 199 | + const textArea = document.createElement('textarea'); |
| 200 | + textArea.value = textToCopy; |
| 201 | + textArea.style.position = 'absolute'; |
| 202 | + textArea.style.left = '-999999px'; |
| 203 | + document.body.append(textArea); |
| 204 | + textArea.focus(); |
| 205 | + textArea.select(); |
| 206 | +
|
| 207 | + try { |
| 208 | + document.execCommand('copy'); |
| 209 | + } catch (error) { |
| 210 | + console.error('Unable to copy to clipboard', error); |
| 211 | + } |
| 212 | +
|
| 213 | + document.body.removeChild(textArea); |
| 214 | + } |
| 215 | +</script> |
0 commit comments