Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' of github.com:erxes/erxes-community into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
munkhsaikhan committed Sep 29, 2023
2 parents cc5faad + 9e33c78 commit 0af8113
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/plugin-payment-api/src/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ router.post('/gateway/storepay', async (req, res) => {

router.post('/gateway/updateInvoice', async (req, res) => {
const { selectedPaymentId, paymentKind, invoiceData, phone } = req.body;

const subdomain = getSubdomain(req);
const models = await generateModels(subdomain);

Expand Down
23 changes: 15 additions & 8 deletions packages/plugin-payment-api/src/public/js/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { doc } = require('prettier');

async function onPaymentClick(payment, invoiceData, prefix) {
const modalContent = document.querySelector('.modal-content');
const image = document.getElementById('qr-code');
Expand All @@ -19,9 +17,16 @@ async function onPaymentClick(payment, invoiceData, prefix) {

let isMobile = false;

if (/Mobi/.test(navigator.userAgent)) {
if (
/Mobi/.test(navigator.userAgent) ||
navigator.userAgent === 'Android' ||
navigator.userAgent === 'iPhone' ||
navigator.userAgent === 'Social Pay' ||
navigator.userAgent === 'socialpay'
) {
isMobile = true;
}

image.src = '';

storepayBtn.style.display = 'none';
Expand Down Expand Up @@ -184,20 +189,21 @@ async function onPaymentClick(payment, invoiceData, prefix) {
});
});
}

// hide bank buttons
bankButtons.style.display = 'none';

if (apiResponse.deeplink && isMobile) {
deeplink.style.display = 'block';
deeplink.href = apiResponse.deeplink;
deeplink.target = '_self';
deeplink.target = 'blank';
deeplink.innerHTML = `Open in ${paymentObj.kind}`;

window.open(apiResponse.deeplink, '_self');
window.location.href = apiResponse.deeplink;
window.open(apiResponse.deeplink, 'blank');
}

if (['qpay', 'qpayQuickqr'].includes(data.invoice.paymentKind) && isMobile){
if (['qpay', 'qpayQuickqr'].includes(data.invoice.paymentKind) && isMobile) {
// hide qr image
image.style.display = 'none';
bankButtons.style.display = 'block';
Expand All @@ -214,7 +220,8 @@ async function onPaymentClick(payment, invoiceData, prefix) {
bankButton.classList.add('bank');
bankButton.innerHTML = `<img src="${bankUrl.logo}" class="urlLogo">`;
bankButton.addEventListener('click', function() {
window.open(bankUrl.link, '_self');
window.open(bankUrl.link, 'blank');
window.location.href = bankUrl.link;
});
document.getElementById('bank-buttons').appendChild(bankButton);
});
Expand Down

0 comments on commit 0af8113

Please sign in to comment.