Fixed: Show the payment option in the Payment Resource tab on the checkout page when trying to pay using the PayPal payment method.

This commit is contained in:
Amit sharma
2025-12-05 11:59:28 +05:30
parent 41f97a6b9e
commit 311da0efe7
4 changed files with 174 additions and 67 deletions

View File

@@ -45,3 +45,19 @@
@keyframes rotate {
0% {transform: rotate(0deg);}
100% {transform: rotate(360deg);}}
p.payment_module a#wkPaypalBtn {
background: url(../../img/paypal-payment-icon.png) 15px 8px no-repeat #fbfbfb;
}
.pp-btn-block {
text-align: center;
padding: 20px 0;
background: #fbfbfb;
border-radius: 3px;
border: 1px solid #d6d4d4;
}
#paypal-button-container{
padding: 0px 15px;
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -20,82 +20,141 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
<div id="paypal-button-container"></div>
<div id="wk-overlay" style="display:none;">
<div class="wk-spinner"></div><br/>
{l s='Please wait...' mod='qlopaypalcommerce'}
<div class="row">
<div class="col-xs-12 col-md-12">
<p class="payment_module">
<a id="wkPaypalBtn" style="cursor:pointer;" href="javascript:void(0);"
title="{l s='PayPal Checkout' mod='qlopaypalcommerce'}">
{l s='PayPal Checkout' mod='qlopaypalcommerce'}
</a>
<div class="pp-btn-block" style="display:none;">
<div id="paypal-button-container"></div>
<div id="wk-overlay" style="display:none;">
<div class="wk-spinner"></div><br />
{l s='Please wait...' mod='qlopaypalcommerce'}
</div>
</div>
</p>
</div>
</div>
<script>
paypal.Buttons({
env: pp_environment,
style: {
layout: 'vertical', // horizontal | vertical
size: 'responsive', // medium | large | responsive
shape: 'rect', // pill | rect
color: 'gold' // gold | blue | silver | black,
},
commit: false,
createOrder: function() {
return fetch(create_order, {
method: 'POST',
body: JSON.stringify({
'update': null,
'flow': 'shortcut'
}),
}).then(function(response) {
return response.json();
}).then(function(dataJson) {
return dataJson.data.id;
});
},
onApprove: function(data, actions) {
$('#wk-overlay').show();
$(document).ready(function() {
var rendered = false;
return fetch(capture_order, {
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID,
getOrderData: true,
}),
method: "POST",
}).then(function(res) {
return res.json();
}).then(function(details) {
if (details.id) {
const postData = {
key: "order_id",
value: details.id
};
submitForm(capture_order, postData);
} else if (details.details[0].issue === 'INSTRUMENT_DECLINED') {
return actions.restart();
} else {
console.log(details);
window.location.replace(error_order + '?err_name=' + details.details[0].issue + '&err_msg=' + details.details[0].description);
}
});
},
onCancel: function(data) {
let url = cancel_order,
postData = {
key: "error",
value: JSON.stringify(data)
};
submitForm(url, postData);
},
onError: function (error) {
console.log(error.data.details[0].issue + ' : ' + error.data.details[0].description);
window.location.replace(error_order + '?err_name=' + error.data.details[0].issue + '&err_msg=' + error.data.details[0].description);
function initPaypalIfReady() {
if (rendered) return;
if (
typeof mp_pp_enabled !== "undefined" &&
mp_pp_enabled &&
$("#paypal-button-container").length
) {
rendered = true;
$("#wkPaypalBtn").addClass("active");
$(".pp-btn-block").show();
renderPayPalButton();
}
}
}).render('#paypal-button-container');
initPaypalIfReady();
const observer = new MutationObserver(() => initPaypalIfReady());
observer.observe(document.body, { childList: true, subtree: true });
const checkRendered = setInterval(() => {
if (rendered) {
observer.disconnect();
clearInterval(checkRendered);
}
}, 500);
$('#wkPaypalBtn').on('click', function() {
$(this).toggleClass("active");
if (!rendered) {
rendered = true;
$(".pp-btn-block").slideDown();
renderPayPalButton();
} else {
$(".pp-btn-block").slideToggle();
}
});
});
function renderPayPalButton() {
paypal.Buttons({
env: pp_environment,
style: {
layout: 'vertical', // horizontal | vertical
size: 'responsive', // medium | large | responsive
shape: 'rect', // pill | rect
color: 'gold' // gold | blue | silver | black,
},
commit: false,
createOrder: function() {
return fetch(create_order, {
method: 'POST',
body: JSON.stringify({
'update': null,
'flow': 'shortcut'
}),
}).then(function(response) {
return response.json();
}).then(function(dataJson) {
return dataJson.data.id;
});
},
onApprove: function(data, actions) {
$('#wk-overlay').show();
return fetch(capture_order, {
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID,
getOrderData: true,
}),
method: "POST",
}).then(function(res) {
return res.json();
}).then(function(details) {
if (details.id) {
const postData = {
key: "order_id",
value: details.id
};
submitForm(capture_order, postData);
} else if (details.details[0].issue === 'INSTRUMENT_DECLINED') {
return actions.restart();
} else {
console.log(details);
window.location.replace(error_order + '?err_name=' + details.details[0]
.issue +
'&err_msg=' + details.details[0].description);
}
});
},
onCancel: function(data) {
let url = cancel_order,
postData = {
key: "error",
value: JSON.stringify(data)
};
submitForm(url, postData);
},
onError: function(error) {
console.log(error.data.details[0].issue + ' : ' + error.data.details[0].description);
window.location.replace(error_order + '?err_name=' + error.data.details[0].issue +
'&err_msg=' +
error.data.details[0].description);
}
}).render('#paypal-button-container');
}
function submitForm(url, data) {
let form = document.createElement('form'),
input = document.createElement('input');
input.name = data.key;
input.value = data.value;