-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #454 from omise/release-v3.5.0
Bump v3.5.0
- Loading branch information
Showing
6 changed files
with
87 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"email": "[email protected]" | ||
} | ||
], | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"minimum-stability": "stable", | ||
"type": "magento2-module", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 79 additions & 24 deletions
103
view/frontend/templates/checkout/onepage/success/promptpay_additional_info.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,80 @@ | ||
<p> | ||
<?= $block->escapeHtml(__('Amount to pay')) ?>: | ||
<strong> | ||
<?= $block->escapeHtml($block->getOrderAmount()) ?> | ||
</b> | ||
</strong> | ||
<p style="margin:.5rem 0"><?= $block->escapeHtml(__('PromptPay QR Code.')); ?></p> | ||
<div><img id="img_payment_code" src="<?= $block->escapeHtml($block->getImageCode()) ?>" /></div> | ||
<p> | ||
Payment expires at: <?= $block->escapeHtml($block->getChargeExpiresAt()); ?> | ||
</p> | ||
<p> | ||
<button class="action secondary" onclick="window.print ? window.print() : alert('Print not available')"> | ||
<?= $block->escapeHtml(__('Print'))?></button> | ||
</p> | ||
|
||
<div style="padding: 15px; margin: 20px 0; border: 1px solid black"> | ||
<p><strong>To make payment:</strong></p> | ||
<ul style="list-style: auto; margin-bottom: 0px; padding: 0px 15px;"> | ||
<li>Download the QR code or open your preferred bank app to scan it</li> | ||
<li>Check that the payment details are correct</li> | ||
<li>Import the QR code image into your bank app or scan the QR code with your bank app to pay</li> | ||
<li>Share the payment slip from your bank app to the seller</li> | ||
</ul> | ||
<div id="qr-info" style="margin-bottom: 10px;"> | ||
<p> | ||
<?= $block->escapeHtml(__('Amount to pay')) ?>: | ||
<strong> | ||
<?= $block->escapeHtml($block->getOrderAmount()) ?> | ||
</b> | ||
</strong> | ||
<p style="margin:.5rem 0"><?= $block->escapeHtml(__('PromptPay QR Code.')); ?></p> | ||
<div><img id="img_payment_code" src="<?= $block->escapeHtml($block->getImageCode()) ?>" /></div> | ||
<p> | ||
Payment expires in: <span id="countdown"></span> | ||
</p> | ||
<p> | ||
<button class="action secondary" onclick="window.print ? window.print() : alert('Print not available')"> | ||
<?= $block->escapeHtml(__('Print'))?></button> | ||
</p> | ||
|
||
<div style="padding: 15px; margin: 20px 0; border: 1px solid black"> | ||
<p><strong>To make payment:</strong></p> | ||
<ol style="margin-bottom: 0px; padding: 0px 15px;"> | ||
<li>Download the QR code or open your preferred bank app to scan it</li> | ||
<li>Check that the payment details are correct</li> | ||
<li>Import the QR code image into your bank app or scan the QR code with your bank app to pay</li> | ||
<li>Share the payment slip from your bank app to the seller</li> | ||
</ol> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
(function () { | ||
let countDownInterval; | ||
|
||
function calculateCountdown() { | ||
const currentDateTime = new Date(); | ||
const expiresAtDateTime = new Date("<?= $block->escapeHtml($block->getChargeExpiresAt()) ?>"); | ||
const difference = expiresAtDateTime - currentDateTime; | ||
const hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60)); | ||
const seconds = Math.floor((difference % (1000 * 60)) / 1000); | ||
return { hours, minutes, seconds }; | ||
} | ||
|
||
function padZero(num) { | ||
return num.toString().padStart(2, '0'); | ||
} | ||
|
||
function hideQrInfoAndShowPaymentExpired() { | ||
const element = document.getElementById('qr-info') | ||
element.innerHTML = `<div class="messages"> | ||
<div class="message-warning warning message"> | ||
<span>Payment Expired.</span> | ||
</div> | ||
</div>` | ||
} | ||
|
||
function updateCountdown() { | ||
const countdownDisplay = document.getElementById('countdown'); | ||
if(!countdownDisplay) { | ||
return; | ||
} | ||
|
||
const { hours, minutes, seconds } = calculateCountdown(); | ||
|
||
if (hours + minutes + seconds < 0) { | ||
if(countDownInterval) { | ||
clearInterval(countDownInterval) | ||
} | ||
hideQrInfoAndShowPaymentExpired() | ||
return; | ||
} | ||
|
||
countdownDisplay.innerHTML = `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`; | ||
if (!countDownInterval) { | ||
countDownInterval = setInterval(updateCountdown, 1000); | ||
} | ||
} | ||
|
||
updateCountdown() | ||
})() | ||
</script> |