This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from lunar/hosted-checkout
Hosted checkout
- Loading branch information
Showing
72 changed files
with
3,591 additions
and
5,096 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
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 |
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 |
---|---|---|
@@ -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]" | ||
} | ||
] | ||
} |
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,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; | ||
} | ||
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,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); | ||
} | ||
}); | ||
} | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.