Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from lunar/hosted-checkout
Browse files Browse the repository at this point in the history
Hosted checkout
  • Loading branch information
lucionescu authored Dec 15, 2023
2 parents 24da7f3 + d4067bb commit dba8785
Show file tree
Hide file tree
Showing 72 changed files with 3,591 additions and 5,096 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
.DS_Store
vendor
/vendor
logs
node_modules
cypress.env.json
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Joomla VirtueMart plugin for Lunar
# Lunar Online Payments for Joomla VirtueMart

The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.

Expand All @@ -9,13 +9,16 @@ The software is provided “as is”, without warranty of any kind, express or i

## Installation

Once you have installed VirtueMart on your Joomla setup, follow these simple steps:
*NOTE: It requires PHP version >=7.4

Once you have installed VirtueMart on your Joomla setup, follow these simple steps:
1. Signup at [lunar.app](https://lunar.app) (it’s free)
1. Create an account
1. Create an app key for your Joomla website
1. Upload the plugin zip trough the 'Extensions' screen in Joomla.
1. Activate the plugin through the 'Extensions' screen in Joomla.
1. Under VirtueMart payment methods create a new payment method and select Lunar.
1. In the configuration tab, choose the payment method.
1. Insert the app key and your public key in the settings for the Lunar payment gateway you just created


Expand All @@ -32,11 +35,11 @@ Under the VirtueMart Lunar payment method settings, you can:

1. Capture
* In Instant mode, the orders are captured automatically
* In delayed mode you can capture an order by moving the order to the shipped status from pending.
* In Delayed mode you can capture an order by moving the order to the `Shipped` status from pending.
2. Refund
* To refund an order move the order into refunded status.
3. Void
* To void an order move the order into refunded status (if the order was not captured, then will void it).
* To refund an order move the order into `Refunded` status.
3. Void/Cancel
* To void/cancel an order move the order into `Cancelled` status (if the order was not captured, then will void it).

## Available features
1. Capture
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "lunar/plugin-virtuemart",
"description": "Lunar payment gateway for Virtuemart",
"name": "lunar/payments-plugin-virtuemart",
"description": "Lunar Online Payments for Joomla VirtueMart",
"license": "MIT",
"authors": [
{
"name": "Ionut Calara",
"email": "[email protected]"
"name": "Lunar",
"email": "[email protected]"
}
]
}
Binary file removed lunar.zip
Binary file not shown.
78 changes: 0 additions & 78 deletions lunar/assets/lunar.css
Original file line number Diff line number Diff line change
@@ -1,78 +0,0 @@
#lunar {
background-color: #005e8d;
border-radius: 5px;
color: #fff;
display: inline-block;
margin-top: 6px;
padding: 5px 20px;
}

.order_details strong {
display: block;
font-size: 14px;
}

.orderDetail .order_details {
list-style: outside none none;
margin: 0;
padding: 0;
}

.order_details li {
font-size: 16px;
list-style: outside none none;
padding: 5px 0 !important;
line-height: 24px;
}

.order_details a {
background: #005e8d none repeat scroll 0 0;
border-radius: 6px;
color: #fff;
padding: 6px 20px;
}

.payment_logo {
display: inline-block;
margin-left: 6px;
}

.payment_box.payment_method_lunar, .lunar_desc {
font-family: sans-serif, serif;
font-size: 14px;
padding: 0px 30px 0;
margin-top: 2px;
margin-bottom: 10px;
}

.lunar-wrapper {
padding-left: 16px;
}

.vm-payment-select .lunar-wrapper {
padding-left: 0;
vertical-align: top;
max-width: 195px;
margin-top: -5px;
}

.lunar_title {
float: left;
font-size: 14px;
font-weight: 600;
padding: 6px 0;
}

.payment_logo img {
margin: 0 2px 0 0;
width: 45px;
}

.orderDetail > h3 {
font-size: 18px;
}

.order_details > li a {
color: #fff;
text-decoration: none;
}
238 changes: 0 additions & 238 deletions lunar/assets/lunar.js
Original file line number Diff line number Diff line change
@@ -1,238 +0,0 @@
lunarSubmitHandler();
checkoutFormbtn ='checkout';
jQuery(function() {

jQuery("#afterOrderLunar").click(function() {
popup(function(r,datas) {
jQuery(".vm-order-done").show();
jQuery('#myModal .modal-footer button').trigger('click');
postData(r.transaction.id,datas.paymentmethod_id);
});
});
jQuery('#checkoutForm').on('click',function(e){
var $btn = '';
if(e.target.type != 'submit') {
$btn = jQuery(e.target).parent();
} else $btn = jQuery(e.target);
if( $btn.attr('type') == 'submit') {
checkoutFormbtn = $btn.attr('name');
//.is('[type="submit"]');
//checkoutFormbtn = jQuery(this).attr('name');
}
});
});

function popup(callback) {
var datas = get_api_info();
var lunar = Paylike({key: datas.publicKey});
var virtuemartOrderId = jQuery("[name=virtuemart_order_id]").val();
data = {};
i = 0;
k = 0;
// jQuery("[name='lunarProductId[]']").each(function() {
// data[k] = Array();
// data[k]["Id"] = jQuery(this).val();
// k++;
// });
// jQuery("[name='lunarProductName[]']").each(function() {
// data[i]["Name"] = jQuery(this).val();
// i++;
// });
// j = 0;

// jQuery("[name='lunarQuantity[]']").each(function() {
// data[j]["Qty"] = jQuery(this).val();
// j++;
// });

lunar.pay({
test: ('1' == datas.testMode) ? (true) : (false),
title: datas.popupTitle,
amount: {
currency: datas.currency,
exponent: datas.exponent,
value: datas.amount
},
locale: datas.locale,
custom: {
lunarID : datas.lunarID,
orderId: datas.orderId,
orderNo: virtuemartOrderId,
products: datas.products,
customer: datas.customer,
platform: datas.platform,
ecommerce: datas.ecommerce,
lunarPluginVersion: datas.version
}
}, function(err, r) {
if (r != undefined) {
var payData = {
'paymentType' : 'captureTransactionFull',
'transactionId' : r.transaction.id,
'virtuemart_paymentmethod_id' : datas.paymentmethod_id,
}
jQuery.ajax({
type: "POST",
url: vmSiteurl + "index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=lunar&format=ajax",
async: false,
data: payData,
success: function(txt) {
if(txt =='1') callback(r,datas);
}
});
}
});
}

function get_api_key() {
var lunarPaymentMethod = jQuery("[name=lunarPaymentMethod]").val();
var s = "";
jQuery.ajax({
type: "POST",
url: vmSiteurl + "index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=lunar&format=ajax&virtuemart_paymentmethod_id=" + lunarPaymentMethod,
async: false,
data: "",
success: function(e) {
s = e
}
});
return s
}
function get_api_info() {
var methodId = jQuery("[name=virtuemart_paymentmethod_id]:checked").val();
if(typeof (methodId) === "undefined") methodId = vmLunar.methodId;
var s = "";
jQuery.ajax({
type: "POST",
url: vmLunar.site + "index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=lunar&format=ajax&virtuemart_paymentmethod_id=" + methodId,
async: false,
data: "",
success: function(e) {
s = e;
},
dataType: "json"
});
return s
}

function lunarSubmitHandler() {
var $Form = jQuery('#checkoutForm');

jQuery(document).on('submit', '#checkoutForm', function(event) {
var $submit = jQuery('#checkoutFormSubmit'),
name = $submit.attr('name');

if (name !== 'confirm' || checkoutFormbtn !=='checkout') {
return true;
}
var methodId = jQuery("[name=virtuemart_paymentmethod_id]:checked").val();
if (!vmLunar.method.hasOwnProperty(methodId)) {
//in case we have no methods, then use default
if(jQuery("[name=virtuemart_paymentmethod_id]").length == 0) {
methodId = vmLunar.methodId;
} else console.log(methodId + "not found");
}
var data = vmLunar.method[methodId];

var lunarMode = jQuery("[name=lunarMode]").val();
var payment_sent = $submit.hasClass('payment_sent');
var payment_after = $submit.hasClass('payment_after');
if (payment_sent || payment_after) {
return true;
}

jQuery(this).vm2front('stopVmLoading');
$submit.attr('disabled',false)
.removeClass( 'vm-button' )
.addClass( 'vm-button-correct' );
var name = $submit.attr('name');
jQuery('#checkoutForm').find('input:hidden[name="'+name+'"]').remove();
event.preventDefault();
if (lunarMode == 'after') {
$submit.addClass("payment_after");
var prevHref = jQuery(this).attr("action");
if (prevHref.indexOf("?") >= 0) {
jQuery(this).attr("action", prevHref + "&payment=1");
} else {
jQuery(this).attr("action", prevHref + "?payment=1");
}
jQuery(this).submit();
return false;
}
popup(function() {
$submit.addClass("payment_sent").trigger("click");
});
return false;
});
}

jQuery(document).ready(function() {

i = 0;
if (jQuery("[name=order_virtuemart_paymentmethod_id]").length > 0) {
jQuery(".orderStatFormSubmit").unbind('click');
jQuery("[name=orderStatForm]").attr("name", "orderStatFormTest")
jQuery(".orderStatFormSubmit").click(function(event) {
var orderNumber = jQuery("[name=orderId]").val();
var delayOrderStatus = jQuery("[name=delayOrderStatus]").val();
var status = jQuery("#order_items_status_chzn span").text().toLowerCase();
var dataToSendForComplete = Array();
var dataToSendForRefund = Array();
var dataToSendForRefundHalf = Array();
if (status == "completed" || status == "shipped" || status == delayOrderStatus) {
dataToSendForComplete.push(orderNumber);
i++;
}
if (status == "refunded" || status == "cancelled") {
dataToSendForRefund.push(orderNumber);
i++;
}
if (status == "refund half") {
dataToSendForRefundHalf.push(orderNumber);
i++;
}
if (dataToSendForRefund.length == 0) {
dataToSendForRefund = "";
} else {
dataToSendForRefund = JSON.stringify(dataToSendForRefund);
}
if (dataToSendForComplete.length == 0) {
dataToSendForComplete = "";
} else {
dataToSendForComplete = JSON.stringify(dataToSendForComplete);
}
if (dataToSendForRefundHalf.length == 0) {
dataToSendForRefundHalf = "";
} else {
dataToSendForRefundHalf = JSON.stringify(dataToSendForRefundHalf);
}
if (i > 0) {
jQuery.ajax({
type: "POST",
url: vmSiteurl + "index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=lunar&format=ajax&CapturePayment=true" + "&dataToSendForComplete=" + dataToSendForComplete + "&dataToSendForRefund=" + dataToSendForRefund + "&dataToSendForRefundHalf=" + dataToSendForRefundHalf,
async: false,
data: "",
success: function(e) {
jQuery("[name=orderStatFormTest]").attr("name", "orderStatForm");
jQuery("[name=orderStatForm]").submit();
}
});
}
return false;

});
}
});

function postData(transactionId,methodId) {
var virtuemart_order_id = jQuery("[name=virtuemart_order_id]").val();
jQuery.ajax({
type: "POST",
url: vmSiteurl + "index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=lunar&format=ajax&save=1&transactionId=" + transactionId+"&virtuemart_paymentmethod_id="+methodId+"&virtuemart_order_id="+virtuemart_order_id,
async: false,
data: "",
success: function(data) {
if(data !='1') alert('error :'+data);
}
});
}
Binary file added lunar/images/maestro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/images/mastercard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/images/mobilepay-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/images/visa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/images/visaelectron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dba8785

Please sign in to comment.