mirror of
https://github.com/pretix/pretix.git
synced 2026-10-03 19:34:41 +00:00
ESlint: Ignore vendored and pre-vue code (#6541)
* ESlint: Ignore vendored and pre-vue code * Format pre-vue code with eslint where possible --------- Co-authored-by: Kara Engelhardt <engelhardt@pretix.eu>
This commit is contained in:
co-authored by
Kara Engelhardt
parent
d9b5fa5b16
commit
d85e52c83e
@@ -1,183 +1,183 @@
|
||||
/*global $, gettext*/
|
||||
/* global gettext */
|
||||
var bankimport_transactionlist = {
|
||||
|
||||
_btn_click: function (e) {
|
||||
console.log(e.delegateTarget);
|
||||
var trans_id = parseInt($(e.delegateTarget).attr("name").split("_")[1]);
|
||||
var value = $(e.delegateTarget).val();
|
||||
if (value === "discard") {
|
||||
bankimport_transactionlist.discard(trans_id);
|
||||
} else if (value === "accept") {
|
||||
bankimport_transactionlist.accept(trans_id);
|
||||
} else if (value === "retry") {
|
||||
bankimport_transactionlist.retry(trans_id);
|
||||
} else if (value === "assign") {
|
||||
bankimport_transactionlist.assign(trans_id);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
_btn_click: function (e) {
|
||||
console.log(e.delegateTarget)
|
||||
let trans_id = parseInt($(e.delegateTarget).attr('name').split('_')[1])
|
||||
let value = $(e.delegateTarget).val()
|
||||
if (value === 'discard') {
|
||||
bankimport_transactionlist.discard(trans_id)
|
||||
} else if (value === 'accept') {
|
||||
bankimport_transactionlist.accept(trans_id)
|
||||
} else if (value === 'retry') {
|
||||
bankimport_transactionlist.retry(trans_id)
|
||||
} else if (value === 'assign') {
|
||||
bankimport_transactionlist.assign(trans_id)
|
||||
}
|
||||
return false
|
||||
},
|
||||
|
||||
_action: function (id, action, success) {
|
||||
$("tr[data-id=" + id + "] button").prop("disabled", true);
|
||||
var data = {
|
||||
"csrfmiddlewaretoken": $("[name=csrfmiddlewaretoken]").val()
|
||||
};
|
||||
data["action_" + id] = action;
|
||||
$.ajax({
|
||||
"method": "POST",
|
||||
"url": $(".transaction-list").attr("data-url"),
|
||||
"data": data,
|
||||
"dataType": "json",
|
||||
"success": function (data) {
|
||||
if (data.status == "ok") {
|
||||
$("tr[data-id=" + id + "]").removeClass("has-error");
|
||||
if (data.comment) {
|
||||
bankimport_transactionlist.comment_reset_to_text(id, data.comment, data.plain);
|
||||
}
|
||||
success();
|
||||
} else {
|
||||
$("tr[data-id=" + id + "] button").prop("disabled", false);
|
||||
$("tr[data-id=" + id + "] .help-block").remove();
|
||||
$("tr[data-id=" + id + "]").addClass("has-error");
|
||||
$("<p>").addClass("help-block").text(data.message).appendTo($("tr[data-id=" + id + "] td.actions"));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_action: function (id, action, success) {
|
||||
$('tr[data-id=' + id + '] button').prop('disabled', true)
|
||||
let data = {
|
||||
csrfmiddlewaretoken: $('[name=csrfmiddlewaretoken]').val()
|
||||
}
|
||||
data['action_' + id] = action
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: $('.transaction-list').attr('data-url'),
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.status == 'ok') {
|
||||
$('tr[data-id=' + id + ']').removeClass('has-error')
|
||||
if (data.comment) {
|
||||
bankimport_transactionlist.comment_reset_to_text(id, data.comment, data.plain)
|
||||
}
|
||||
success()
|
||||
} else {
|
||||
$('tr[data-id=' + id + '] button').prop('disabled', false)
|
||||
$('tr[data-id=' + id + '] .help-block').remove()
|
||||
$('tr[data-id=' + id + ']').addClass('has-error')
|
||||
$('<p>').addClass('help-block').text(data.message).appendTo($('tr[data-id=' + id + '] td.actions'))
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
discard: function (id) {
|
||||
bankimport_transactionlist._action(id, "discard", function () {
|
||||
$("tr[data-id=" + id + "] td").remove();
|
||||
});
|
||||
},
|
||||
discard: function (id) {
|
||||
bankimport_transactionlist._action(id, 'discard', function () {
|
||||
$('tr[data-id=' + id + '] td').remove()
|
||||
})
|
||||
},
|
||||
|
||||
retry: function (id) {
|
||||
bankimport_transactionlist._action(id, "retry", function () {
|
||||
$("tr[data-id=" + id + "] td.actions").html('').text(gettext("Marked as paid"));
|
||||
});
|
||||
},
|
||||
retry: function (id) {
|
||||
bankimport_transactionlist._action(id, 'retry', function () {
|
||||
$('tr[data-id=' + id + '] td.actions').html('').text(gettext('Marked as paid'))
|
||||
})
|
||||
},
|
||||
|
||||
accept: function (id) {
|
||||
bankimport_transactionlist._action(id, "accept", function () {
|
||||
$("tr[data-id=" + id + "] td.actions").html('').text(gettext("Marked as paid"));
|
||||
});
|
||||
},
|
||||
accept: function (id) {
|
||||
bankimport_transactionlist._action(id, 'accept', function () {
|
||||
$('tr[data-id=' + id + '] td.actions').html('').text(gettext('Marked as paid'))
|
||||
})
|
||||
},
|
||||
|
||||
assign: function (id) {
|
||||
bankimport_transactionlist._action(id, "assign:" + $("tr[data-id=" + id + "] input.form-control:not(.tt-hint)").val(), function () {
|
||||
$("tr[data-id=" + id + "] td.actions").html('').text(gettext("Marked as paid"));
|
||||
});
|
||||
},
|
||||
assign: function (id) {
|
||||
bankimport_transactionlist._action(id, 'assign:' + $('tr[data-id=' + id + '] input.form-control:not(.tt-hint)').val(), function () {
|
||||
$('tr[data-id=' + id + '] td.actions').html('').text(gettext('Marked as paid'))
|
||||
})
|
||||
},
|
||||
|
||||
comment_reset_to_text: function (id, text, plain) {
|
||||
var $box = $("tr[data-id=" + id + "] .comment-box");
|
||||
$box[0].dataset["plain"] = plain;
|
||||
$box.html("")
|
||||
.append($("<strong>").text(gettext("Comment:")))
|
||||
.append(" ")
|
||||
.append($("<span>").addClass("comment").append(" ").append(text))
|
||||
.append(" ")
|
||||
.append($("<a>").addClass("comment-modify btn btn-default btn-xs")
|
||||
.append("<span class='fa fa-edit'></span>"));
|
||||
},
|
||||
comment_reset_to_text: function (id, text, plain) {
|
||||
let $box = $('tr[data-id=' + id + '] .comment-box')
|
||||
$box[0].dataset['plain'] = plain
|
||||
$box.html('')
|
||||
.append($('<strong>').text(gettext('Comment:')))
|
||||
.append(' ')
|
||||
.append($('<span>').addClass('comment').append(' ').append(text))
|
||||
.append(' ')
|
||||
.append($('<a>').addClass('comment-modify btn btn-default btn-xs')
|
||||
.append('<span class=\'fa fa-edit\'></span>'))
|
||||
},
|
||||
|
||||
comment_start_edit: function (e) {
|
||||
var $box = $(e.target).closest("div");
|
||||
var id = $box.closest("tr").attr("data-id");
|
||||
var $inp = $("<textarea>").addClass("form-control");
|
||||
var orig_rendered = $box.find(".comment");
|
||||
var orig_text = $box[0].dataset.plain;
|
||||
$inp.val(orig_text);
|
||||
comment_start_edit: function (e) {
|
||||
let $box = $(e.target).closest('div')
|
||||
let id = $box.closest('tr').attr('data-id')
|
||||
let $inp = $('<textarea>').addClass('form-control')
|
||||
let orig_rendered = $box.find('.comment')
|
||||
let orig_text = $box[0].dataset.plain
|
||||
$inp.val(orig_text)
|
||||
|
||||
var $btngrp = $("<div>");
|
||||
$btngrp.addClass("btn-group");
|
||||
var $btn1 = $("<button>");
|
||||
$btn1.attr("type", "button").addClass("btn btn-default");
|
||||
$btn1.append("<span class='fa fa-check'></span>");
|
||||
$btngrp.append($btn1);
|
||||
var $btn2 = $("<button>");
|
||||
$btn2.attr("type", "button").addClass("btn btn-default");
|
||||
$btn2.append("<span class='fa fa-close'></span>");
|
||||
$btngrp.append($btn2);
|
||||
$box.html("").append($inp).append($btngrp);
|
||||
$btn1.click(function () {
|
||||
var text = $box.find("textarea").val();
|
||||
$box.find("input, textarea, button").prop("disabled", true);
|
||||
bankimport_transactionlist._action(id, "comment:" + text, function () {
|
||||
$("tr[data-id=" + id + "] button").prop("disabled", false);
|
||||
});
|
||||
});
|
||||
$btn2.click(function () {
|
||||
bankimport_transactionlist.comment_reset_to_text(id, orig_rendered, orig_text);
|
||||
});
|
||||
let $btngrp = $('<div>')
|
||||
$btngrp.addClass('btn-group')
|
||||
let $btn1 = $('<button>')
|
||||
$btn1.attr('type', 'button').addClass('btn btn-default')
|
||||
$btn1.append('<span class=\'fa fa-check\'></span>')
|
||||
$btngrp.append($btn1)
|
||||
let $btn2 = $('<button>')
|
||||
$btn2.attr('type', 'button').addClass('btn btn-default')
|
||||
$btn2.append('<span class=\'fa fa-close\'></span>')
|
||||
$btngrp.append($btn2)
|
||||
$box.html('').append($inp).append($btngrp)
|
||||
$btn1.click(function () {
|
||||
let text = $box.find('textarea').val()
|
||||
$box.find('input, textarea, button').prop('disabled', true)
|
||||
bankimport_transactionlist._action(id, 'comment:' + text, function () {
|
||||
$('tr[data-id=' + id + '] button').prop('disabled', false)
|
||||
})
|
||||
})
|
||||
$btn2.click(function () {
|
||||
bankimport_transactionlist.comment_reset_to_text(id, orig_rendered, orig_text)
|
||||
})
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
e.preventDefault()
|
||||
},
|
||||
|
||||
typeahead_source: function () {
|
||||
return new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: $(".transaction-list").attr("data-url"),
|
||||
prepare: function (query, settings) {
|
||||
settings.url = settings.url + '?query=' + encodeURIComponent(query);
|
||||
return settings;
|
||||
},
|
||||
transform: function (object) {
|
||||
var results = object.results;
|
||||
var suggs = [];
|
||||
var reslen = results.length;
|
||||
for (var i = 0; i < reslen; i++) {
|
||||
suggs.push(results[i]);
|
||||
}
|
||||
return suggs;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
typeahead_source: function () {
|
||||
return new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: $('.transaction-list').attr('data-url'),
|
||||
prepare: function (query, settings) {
|
||||
settings.url = settings.url + '?query=' + encodeURIComponent(query)
|
||||
return settings
|
||||
},
|
||||
transform: function (object) {
|
||||
let results = object.results
|
||||
let suggs = []
|
||||
let reslen = results.length
|
||||
for (let i = 0; i < reslen; i++) {
|
||||
suggs.push(results[i])
|
||||
}
|
||||
return suggs
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if ($(".transaction-list").length) {
|
||||
$(".transaction-list button").click(bankimport_transactionlist._btn_click);
|
||||
init: function () {
|
||||
if ($('.transaction-list').length) {
|
||||
$('.transaction-list button').click(bankimport_transactionlist._btn_click)
|
||||
|
||||
$(".transaction-list").on("click", ".comment-modify", bankimport_transactionlist.comment_start_edit);
|
||||
$('.transaction-list').on('click', '.comment-modify', bankimport_transactionlist.comment_start_edit)
|
||||
|
||||
$(".transaction-list .form-control").typeahead(null, {
|
||||
minLength: 2,
|
||||
name: 'order-dataset',
|
||||
source: bankimport_transactionlist.typeahead_source(),
|
||||
display: function (obj) {
|
||||
return obj.code;
|
||||
},
|
||||
templates: {
|
||||
suggestion: function (obj) {
|
||||
return '<div>' + obj.code + ' (' + obj.total + ', ' + obj.status + ')</div>';
|
||||
}
|
||||
}
|
||||
}).keypress(function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
$(this).parent().parent().find("button[value=assign]").click();
|
||||
}
|
||||
});
|
||||
}
|
||||
$('.transaction-list .form-control').typeahead(null, {
|
||||
minLength: 2,
|
||||
name: 'order-dataset',
|
||||
source: bankimport_transactionlist.typeahead_source(),
|
||||
display: function (obj) {
|
||||
return obj.code
|
||||
},
|
||||
templates: {
|
||||
suggestion: function (obj) {
|
||||
return '<div>' + obj.code + ' (' + obj.total + ', ' + obj.status + ')</div>'
|
||||
}
|
||||
}
|
||||
}).keypress(function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
$(this).parent().parent().find('button[value=assign]').click()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if ($("[data-job-waiting]").length) {
|
||||
window.setTimeout(bankimport_transactionlist.check_state, 750);
|
||||
}
|
||||
},
|
||||
if ($('[data-job-waiting]').length) {
|
||||
window.setTimeout(bankimport_transactionlist.check_state, 750)
|
||||
}
|
||||
},
|
||||
|
||||
check_state: function () {
|
||||
$.getJSON($("[data-job-waiting-url]").attr("data-job-waiting-url"), function (data) {
|
||||
if (data.state == 'running' || data.state == 'pending') {
|
||||
window.setTimeout(bankimport_transactionlist.check_state, 750);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
check_state: function () {
|
||||
$.getJSON($('[data-job-waiting-url]').attr('data-job-waiting-url'), function (data) {
|
||||
if (data.state == 'running' || data.state == 'pending') {
|
||||
window.setTimeout(bankimport_transactionlist.check_state, 750)
|
||||
} else {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
bankimport_transactionlist.init();
|
||||
});
|
||||
bankimport_transactionlist.init()
|
||||
})
|
||||
|
||||
@@ -1,350 +1,350 @@
|
||||
/*global $, paypal_client_id, paypal_loadingmessage, gettext */
|
||||
'use strict';
|
||||
/* global paypal_client_id, paypal_loadingmessage, gettext */
|
||||
'use strict'
|
||||
|
||||
var pretixpaypal = {
|
||||
paypal: null,
|
||||
client_id: null,
|
||||
order_id: null,
|
||||
payer_id: null,
|
||||
merchant_id: null,
|
||||
currency: null,
|
||||
method: null,
|
||||
additional_disabled_funding: null,
|
||||
additional_enabled_funding: null,
|
||||
debug_buyer_country: null,
|
||||
continue_button: null,
|
||||
paypage: false,
|
||||
method_map: {
|
||||
wallet: {
|
||||
method: 'wallet',
|
||||
funding_source: 'paypal',
|
||||
//disable_funding: null,
|
||||
//enable_funding: 'paylater',
|
||||
early_auth: true,
|
||||
},
|
||||
apm: {
|
||||
method: 'apm',
|
||||
funding_source: null,
|
||||
//disable_funding: null,
|
||||
//enable_funding: null,
|
||||
early_auth: false,
|
||||
}
|
||||
},
|
||||
apm_map: {
|
||||
paypal: gettext('PayPal'),
|
||||
venmo: gettext('Venmo'),
|
||||
applepay: gettext('Apple Pay'),
|
||||
itau: gettext('Itaú'),
|
||||
credit: gettext('PayPal Credit'),
|
||||
card: gettext('Credit Card'),
|
||||
paylater: gettext('PayPal Pay Later'),
|
||||
ideal: gettext('iDEAL | Wero'),
|
||||
sepa: gettext('SEPA Direct Debit'),
|
||||
bancontact: gettext('Bancontact'),
|
||||
giropay: gettext('giropay'),
|
||||
sofort: gettext('SOFORT'),
|
||||
eps: gettext('eps'),
|
||||
mybank: gettext('MyBank'),
|
||||
p24: gettext('Przelewy24'),
|
||||
verkkopankki: gettext('Verkkopankki'),
|
||||
payu: gettext('PayU'),
|
||||
blik: gettext('BLIK'),
|
||||
trustly: gettext('Trustly'),
|
||||
zimpler: gettext('Zimpler'),
|
||||
maxima: gettext('Maxima'),
|
||||
oxxo: gettext('OXXO'),
|
||||
boleto: gettext('Boleto'),
|
||||
wechatpay: gettext('WeChat Pay'),
|
||||
mercadopago: gettext('Mercado Pago')
|
||||
},
|
||||
readyToSubmitApproval: false,
|
||||
paypal: null,
|
||||
client_id: null,
|
||||
order_id: null,
|
||||
payer_id: null,
|
||||
merchant_id: null,
|
||||
currency: null,
|
||||
method: null,
|
||||
additional_disabled_funding: null,
|
||||
additional_enabled_funding: null,
|
||||
debug_buyer_country: null,
|
||||
continue_button: null,
|
||||
paypage: false,
|
||||
method_map: {
|
||||
wallet: {
|
||||
method: 'wallet',
|
||||
funding_source: 'paypal',
|
||||
// disable_funding: null,
|
||||
// enable_funding: 'paylater',
|
||||
early_auth: true,
|
||||
},
|
||||
apm: {
|
||||
method: 'apm',
|
||||
funding_source: null,
|
||||
// disable_funding: null,
|
||||
// enable_funding: null,
|
||||
early_auth: false,
|
||||
}
|
||||
},
|
||||
apm_map: {
|
||||
paypal: gettext('PayPal'),
|
||||
venmo: gettext('Venmo'),
|
||||
applepay: gettext('Apple Pay'),
|
||||
itau: gettext('Itaú'),
|
||||
credit: gettext('PayPal Credit'),
|
||||
card: gettext('Credit Card'),
|
||||
paylater: gettext('PayPal Pay Later'),
|
||||
ideal: gettext('iDEAL | Wero'),
|
||||
sepa: gettext('SEPA Direct Debit'),
|
||||
bancontact: gettext('Bancontact'),
|
||||
giropay: gettext('giropay'),
|
||||
sofort: gettext('SOFORT'),
|
||||
eps: gettext('eps'),
|
||||
mybank: gettext('MyBank'),
|
||||
p24: gettext('Przelewy24'),
|
||||
verkkopankki: gettext('Verkkopankki'),
|
||||
payu: gettext('PayU'),
|
||||
blik: gettext('BLIK'),
|
||||
trustly: gettext('Trustly'),
|
||||
zimpler: gettext('Zimpler'),
|
||||
maxima: gettext('Maxima'),
|
||||
oxxo: gettext('OXXO'),
|
||||
boleto: gettext('Boleto'),
|
||||
wechatpay: gettext('WeChat Pay'),
|
||||
mercadopago: gettext('Mercado Pago')
|
||||
},
|
||||
readyToSubmitApproval: false,
|
||||
|
||||
load: function () {
|
||||
if (pretixpaypal.paypal === null) {
|
||||
pretixpaypal.client_id = $.trim($("#paypal_client_id").html());
|
||||
pretixpaypal.merchant_id = $.trim($("#paypal_merchant_id").html());
|
||||
pretixpaypal.debug_buyer_country = $.trim($("#paypal_buyer_country").html());
|
||||
pretixpaypal.continue_button = $('.checkout-button-row').closest("form").find(".checkout-button-row .btn-primary");
|
||||
pretixpaypal.continue_button.closest('div').append('<div id="paypal-button-container"></div>');
|
||||
pretixpaypal.additional_disabled_funding = $.trim($("#paypal_disable_funding").html());
|
||||
pretixpaypal.additional_enabled_funding = $.trim($("#paypal_enable_funding").html());
|
||||
pretixpaypal.paypage = Boolean($('#paypal-button-container').data('paypage'));
|
||||
pretixpaypal.order_id = $.trim($("#paypal_oid").html());
|
||||
pretixpaypal.currency = $("body").attr("data-currency");
|
||||
pretixpaypal.locale = this.guessLocale();
|
||||
}
|
||||
load: function () {
|
||||
if (pretixpaypal.paypal === null) {
|
||||
pretixpaypal.client_id = $.trim($('#paypal_client_id').html())
|
||||
pretixpaypal.merchant_id = $.trim($('#paypal_merchant_id').html())
|
||||
pretixpaypal.debug_buyer_country = $.trim($('#paypal_buyer_country').html())
|
||||
pretixpaypal.continue_button = $('.checkout-button-row').closest('form').find('.checkout-button-row .btn-primary')
|
||||
pretixpaypal.continue_button.closest('div').append('<div id="paypal-button-container"></div>')
|
||||
pretixpaypal.additional_disabled_funding = $.trim($('#paypal_disable_funding').html())
|
||||
pretixpaypal.additional_enabled_funding = $.trim($('#paypal_enable_funding').html())
|
||||
pretixpaypal.paypage = Boolean($('#paypal-button-container').data('paypage'))
|
||||
pretixpaypal.order_id = $.trim($('#paypal_oid').html())
|
||||
pretixpaypal.currency = $('body').attr('data-currency')
|
||||
pretixpaypal.locale = this.guessLocale()
|
||||
}
|
||||
|
||||
$("input[name=payment][value^='paypal']").change(function () {
|
||||
if (pretixpaypal.paypal !== null) {
|
||||
pretixpaypal.renderButton($(this).val());
|
||||
} else {
|
||||
pretixpaypal.continue_button.prop("disabled", true);
|
||||
}
|
||||
});
|
||||
$('input[name=payment][value^=\'paypal\']').change(function () {
|
||||
if (pretixpaypal.paypal !== null) {
|
||||
pretixpaypal.renderButton($(this).val())
|
||||
} else {
|
||||
pretixpaypal.continue_button.prop('disabled', true)
|
||||
}
|
||||
})
|
||||
|
||||
$("input[name=payment]").not("[value^='paypal']").change(function () {
|
||||
pretixpaypal.restore();
|
||||
});
|
||||
$('input[name=payment]').not('[value^=\'paypal\']').change(function () {
|
||||
pretixpaypal.restore()
|
||||
})
|
||||
|
||||
// If paypal is pre-selected, we must disable the continue button and handle it after SDK is loaded
|
||||
if ($("input[name=payment][value^='paypal']").is(':checked')) {
|
||||
pretixpaypal.continue_button.prop("disabled", true);
|
||||
}
|
||||
// If paypal is pre-selected, we must disable the continue button and handle it after SDK is loaded
|
||||
if ($('input[name=payment][value^=\'paypal\']').is(':checked')) {
|
||||
pretixpaypal.continue_button.prop('disabled', true)
|
||||
}
|
||||
|
||||
// We are setting the cogwheel already here, as the renderAPM() method might take some time to get loaded.
|
||||
const apmtextselector = $("input[name=payment][value=paypal_apm]").closest("label").find(".accordion-label-text");
|
||||
apmtextselector.append(' <span aria-hidden="true" class="fa fa-cog fa-spin"></span>');
|
||||
// We are setting the cogwheel already here, as the renderAPM() method might take some time to get loaded.
|
||||
const apmtextselector = $('input[name=payment][value=paypal_apm]').closest('label').find('.accordion-label-text')
|
||||
apmtextselector.append(' <span aria-hidden="true" class="fa fa-cog fa-spin"></span>')
|
||||
|
||||
let sdk_url = 'https://www.paypal.com/sdk/js' +
|
||||
'?client-id=' + pretixpaypal.client_id +
|
||||
'&components=buttons,funding-eligibility' +
|
||||
'¤cy=' + pretixpaypal.currency;
|
||||
let sdk_url = 'https://www.paypal.com/sdk/js'
|
||||
+ '?client-id=' + pretixpaypal.client_id
|
||||
+ '&components=buttons,funding-eligibility'
|
||||
+ '¤cy=' + pretixpaypal.currency
|
||||
|
||||
if (pretixpaypal.locale) {
|
||||
sdk_url += '&locale=' + pretixpaypal.locale;
|
||||
}
|
||||
if (pretixpaypal.locale) {
|
||||
sdk_url += '&locale=' + pretixpaypal.locale
|
||||
}
|
||||
|
||||
if (pretixpaypal.merchant_id) {
|
||||
sdk_url += '&merchant-id=' + pretixpaypal.merchant_id;
|
||||
}
|
||||
if (pretixpaypal.merchant_id) {
|
||||
sdk_url += '&merchant-id=' + pretixpaypal.merchant_id
|
||||
}
|
||||
|
||||
if (pretixpaypal.additional_disabled_funding) {
|
||||
sdk_url += '&disable-funding=' + [pretixpaypal.additional_disabled_funding].filter(Boolean).join(',');
|
||||
}
|
||||
if (pretixpaypal.additional_disabled_funding) {
|
||||
sdk_url += '&disable-funding=' + [pretixpaypal.additional_disabled_funding].filter(Boolean).join(',')
|
||||
}
|
||||
|
||||
if (pretixpaypal.additional_enabled_funding) {
|
||||
sdk_url += '&enable-funding=' + [pretixpaypal.additional_enabled_funding].filter(Boolean).join(',');
|
||||
}
|
||||
if (pretixpaypal.additional_enabled_funding) {
|
||||
sdk_url += '&enable-funding=' + [pretixpaypal.additional_enabled_funding].filter(Boolean).join(',')
|
||||
}
|
||||
|
||||
if (pretixpaypal.debug_buyer_country) {
|
||||
sdk_url += '&buyer-country=' + pretixpaypal.debug_buyer_country;
|
||||
}
|
||||
if (pretixpaypal.debug_buyer_country) {
|
||||
sdk_url += '&buyer-country=' + pretixpaypal.debug_buyer_country
|
||||
}
|
||||
|
||||
let ppscript = document.createElement('script');
|
||||
let ready = false;
|
||||
let head = document.getElementsByTagName("head")[0];
|
||||
ppscript.setAttribute('src', sdk_url);
|
||||
ppscript.setAttribute('data-csp-nonce', $.trim($("#csp_nonce").html()));
|
||||
ppscript.setAttribute('data-page-type', 'checkout');
|
||||
ppscript.setAttribute('data-partner-attribution-id', 'ramiioGmbH_Cart_PPCP');
|
||||
document.head.appendChild(ppscript);
|
||||
let ppscript = document.createElement('script')
|
||||
let ready = false
|
||||
let head = document.getElementsByTagName('head')[0]
|
||||
ppscript.setAttribute('src', sdk_url)
|
||||
ppscript.setAttribute('data-csp-nonce', $.trim($('#csp_nonce').html()))
|
||||
ppscript.setAttribute('data-page-type', 'checkout')
|
||||
ppscript.setAttribute('data-partner-attribution-id', 'ramiioGmbH_Cart_PPCP')
|
||||
document.head.appendChild(ppscript)
|
||||
|
||||
ppscript.onload = ppscript.onreadystatechange = function () {
|
||||
if (!ready && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
|
||||
ready = true;
|
||||
ppscript.onload = ppscript.onreadystatechange = function () {
|
||||
if (!ready && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
|
||||
ready = true
|
||||
|
||||
pretixpaypal.paypal = paypal;
|
||||
pretixpaypal.paypal = paypal
|
||||
|
||||
// Handle memory leak in IE
|
||||
ppscript.onload = ppscript.onreadystatechange = null;
|
||||
if (head && ppscript.parentNode) {
|
||||
head.removeChild(ppscript);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Handle memory leak in IE
|
||||
ppscript.onload = ppscript.onreadystatechange = null
|
||||
if (head && ppscript.parentNode) {
|
||||
head.removeChild(ppscript)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("visibilitychange", this.onApproveSubmit);
|
||||
},
|
||||
document.addEventListener('visibilitychange', this.onApproveSubmit)
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
if ($("input[name=payment][value=paypal_apm]").length > 0) {
|
||||
pretixpaypal.renderAPMs();
|
||||
}
|
||||
ready: function () {
|
||||
if ($('input[name=payment][value=paypal_apm]').length > 0) {
|
||||
pretixpaypal.renderAPMs()
|
||||
}
|
||||
|
||||
if ($("input[name=payment][value^='paypal']").is(':checked')) {
|
||||
pretixpaypal.renderButton($("input[name=payment][value^='paypal']:checked").val());
|
||||
} else if ($(".payment-redo-form").length) {
|
||||
pretixpaypal.renderButton($("input[name=payment][value^='paypal']").val());
|
||||
} else if ($('#paypal-button-container').data('paypage')) {
|
||||
pretixpaypal.renderButton('paypal_apm');
|
||||
}
|
||||
},
|
||||
if ($('input[name=payment][value^=\'paypal\']').is(':checked')) {
|
||||
pretixpaypal.renderButton($('input[name=payment][value^=\'paypal\']:checked').val())
|
||||
} else if ($('.payment-redo-form').length) {
|
||||
pretixpaypal.renderButton($('input[name=payment][value^=\'paypal\']').val())
|
||||
} else if ($('#paypal-button-container').data('paypage')) {
|
||||
pretixpaypal.renderButton('paypal_apm')
|
||||
}
|
||||
},
|
||||
|
||||
restore: function () {
|
||||
// if PayPal has not been initialized, there shouldn't be anything to cleanup
|
||||
if (pretixpaypal.paypal !== null) {
|
||||
$('#paypal-button-container').empty()
|
||||
pretixpaypal.continue_button.text(gettext('Continue'));
|
||||
pretixpaypal.continue_button.show();
|
||||
}
|
||||
pretixpaypal.continue_button.prop("disabled", false);
|
||||
},
|
||||
restore: function () {
|
||||
// if PayPal has not been initialized, there shouldn't be anything to cleanup
|
||||
if (pretixpaypal.paypal !== null) {
|
||||
$('#paypal-button-container').empty()
|
||||
pretixpaypal.continue_button.text(gettext('Continue'))
|
||||
pretixpaypal.continue_button.show()
|
||||
}
|
||||
pretixpaypal.continue_button.prop('disabled', false)
|
||||
},
|
||||
|
||||
renderButton: function (method) {
|
||||
if (method === 'paypal') {
|
||||
method = "wallet"
|
||||
} else {
|
||||
method = method.split('paypal_').at(-1)
|
||||
}
|
||||
pretixpaypal.method = pretixpaypal.method_map[method];
|
||||
renderButton: function (method) {
|
||||
if (method === 'paypal') {
|
||||
method = 'wallet'
|
||||
} else {
|
||||
method = method.split('paypal_').at(-1)
|
||||
}
|
||||
pretixpaypal.method = pretixpaypal.method_map[method]
|
||||
|
||||
if (pretixpaypal.method.method === 'apm' && !pretixpaypal.paypage) {
|
||||
pretixpaypal.restore();
|
||||
return;
|
||||
}
|
||||
if (pretixpaypal.method.method === 'apm' && !pretixpaypal.paypage) {
|
||||
pretixpaypal.restore()
|
||||
return
|
||||
}
|
||||
|
||||
$('#paypal-button-container').empty()
|
||||
$('#paypal-card-container').empty()
|
||||
$('#paypal-button-container').empty()
|
||||
$('#paypal-card-container').empty()
|
||||
|
||||
let button = pretixpaypal.paypal.Buttons({
|
||||
fundingSource: pretixpaypal.method.funding_source,
|
||||
style: {
|
||||
layout: pretixpaypal.method.early_auth ? 'horizontal' : 'vertical',
|
||||
//color: 'white',
|
||||
shape: 'rect',
|
||||
label: 'pay',
|
||||
tagline: false
|
||||
},
|
||||
createOrder: function (data, actions) {
|
||||
if (pretixpaypal.order_id) {
|
||||
return pretixpaypal.order_id;
|
||||
}
|
||||
let button = pretixpaypal.paypal.Buttons({
|
||||
fundingSource: pretixpaypal.method.funding_source,
|
||||
style: {
|
||||
layout: pretixpaypal.method.early_auth ? 'horizontal' : 'vertical',
|
||||
// color: 'white',
|
||||
shape: 'rect',
|
||||
label: 'pay',
|
||||
tagline: false
|
||||
},
|
||||
createOrder: function (data, actions) {
|
||||
if (pretixpaypal.order_id) {
|
||||
return pretixpaypal.order_id
|
||||
}
|
||||
|
||||
// On the paypal:pay view, we already pregenerated the OID.
|
||||
// Since this view is also only used for APMs, we only need the XHR-calls for the Smart Payment Buttons.
|
||||
if (pretixpaypal.paypage) {
|
||||
return $("#payment_paypal_" + pretixpaypal.method.method + "_oid");
|
||||
} else {
|
||||
var xhrurl = $("#payment_paypal_" + pretixpaypal.method.method + "_xhr").val();
|
||||
}
|
||||
// On the paypal:pay view, we already pregenerated the OID.
|
||||
// Since this view is also only used for APMs, we only need the XHR-calls for the Smart Payment Buttons.
|
||||
if (pretixpaypal.paypage) {
|
||||
return $('#payment_paypal_' + pretixpaypal.method.method + '_oid')
|
||||
} else {
|
||||
var xhrurl = $('#payment_paypal_' + pretixpaypal.method.method + '_xhr').val()
|
||||
}
|
||||
|
||||
return fetch(xhrurl, {
|
||||
method: 'POST'
|
||||
}).then(function (res) {
|
||||
return res.json();
|
||||
}).then(function (data) {
|
||||
if ('id' in data) {
|
||||
return data.id;
|
||||
} else {
|
||||
// Refreshing the page to surface the request-error message
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
},
|
||||
onApprove: function (data, actions) {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
pretixpaypal.order_id = data.orderID;
|
||||
pretixpaypal.payer_id = data.payerID;
|
||||
return fetch(xhrurl, {
|
||||
method: 'POST'
|
||||
}).then(function (res) {
|
||||
return res.json()
|
||||
}).then(function (data) {
|
||||
if ('id' in data) {
|
||||
return data.id
|
||||
} else {
|
||||
// Refreshing the page to surface the request-error message
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
},
|
||||
onApprove: function (data, actions) {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
pretixpaypal.order_id = data.orderID
|
||||
pretixpaypal.payer_id = data.payerID
|
||||
|
||||
let method = pretixpaypal.paypage ? "wallet" : pretixpaypal.method.method;
|
||||
let selectorstub = "#payment_paypal_" + method;
|
||||
// Insert the tokens into the form, so it gets submitted to the server
|
||||
$(selectorstub + "_oid").val(pretixpaypal.order_id);
|
||||
$(selectorstub + "_payer").val(pretixpaypal.payer_id);
|
||||
let method = pretixpaypal.paypage ? 'wallet' : pretixpaypal.method.method
|
||||
let selectorstub = '#payment_paypal_' + method
|
||||
// Insert the tokens into the form, so it gets submitted to the server
|
||||
$(selectorstub + '_oid').val(pretixpaypal.order_id)
|
||||
$(selectorstub + '_payer').val(pretixpaypal.payer_id)
|
||||
|
||||
// We are moving the submission to a separate function, which is also an EventListener, since
|
||||
// SFSafariView refuses to submit a form that is not visible. Unfortunately, that is exactly the case
|
||||
// when the ticket shop is used on iOS within an SFSafariView and the PayPal payment popup has not
|
||||
// closed itself quickly enough.
|
||||
pretixpaypal.readyToSubmitApproval = true;
|
||||
pretixpaypal.onApproveSubmit();
|
||||
// We are moving the submission to a separate function, which is also an EventListener, since
|
||||
// SFSafariView refuses to submit a form that is not visible. Unfortunately, that is exactly the case
|
||||
// when the ticket shop is used on iOS within an SFSafariView and the PayPal payment popup has not
|
||||
// closed itself quickly enough.
|
||||
pretixpaypal.readyToSubmitApproval = true
|
||||
pretixpaypal.onApproveSubmit()
|
||||
|
||||
// billingToken: null
|
||||
// facilitatorAccessToken: "A21AAL_fEu0gDD-sIXyOy65a6MjgSJJrhmxuPcxxUGnL5gW2DzTxiiAksfoC4x8hD-BjeY1LsFVKl7ceuO7UR1a9pQr8Q_AVw"
|
||||
// orderID: "7RF70259NY7589848"
|
||||
// payerID: "8M3BU92Z97VXA"
|
||||
// paymentID: null
|
||||
},
|
||||
});
|
||||
// billingToken: null
|
||||
// facilitatorAccessToken: "A21AAL_fEu0gDD-sIXyOy65a6MjgSJJrhmxuPcxxUGnL5gW2DzTxiiAksfoC4x8hD-BjeY1LsFVKl7ceuO7UR1a9pQr8Q_AVw"
|
||||
// orderID: "7RF70259NY7589848"
|
||||
// payerID: "8M3BU92Z97VXA"
|
||||
// paymentID: null
|
||||
},
|
||||
})
|
||||
|
||||
if (button.isEligible()) {
|
||||
button.render('#paypal-button-container');
|
||||
pretixpaypal.continue_button.hide();
|
||||
} else {
|
||||
pretixpaypal.continue_button.text(gettext('Payment method unavailable'));
|
||||
pretixpaypal.continue_button.show();
|
||||
}
|
||||
},
|
||||
if (button.isEligible()) {
|
||||
button.render('#paypal-button-container')
|
||||
pretixpaypal.continue_button.hide()
|
||||
} else {
|
||||
pretixpaypal.continue_button.text(gettext('Payment method unavailable'))
|
||||
pretixpaypal.continue_button.show()
|
||||
}
|
||||
},
|
||||
|
||||
onApproveSubmit: function() {
|
||||
if (document.visibilityState === "visible" && pretixpaypal.readyToSubmitApproval === true) {
|
||||
let method = pretixpaypal.paypage ? "wallet" : pretixpaypal.method.method;
|
||||
let selectorstub = "#payment_paypal_" + method;
|
||||
var $form = $(selectorstub + "_oid").closest("form");
|
||||
onApproveSubmit: function () {
|
||||
if (document.visibilityState === 'visible' && pretixpaypal.readyToSubmitApproval === true) {
|
||||
let method = pretixpaypal.paypage ? 'wallet' : pretixpaypal.method.method
|
||||
let selectorstub = '#payment_paypal_' + method
|
||||
let $form = $(selectorstub + '_oid').closest('form')
|
||||
|
||||
$form.get(0).submit();
|
||||
}
|
||||
},
|
||||
$form.get(0).submit()
|
||||
}
|
||||
},
|
||||
|
||||
renderAPMs: function () {
|
||||
pretixpaypal.restore();
|
||||
let inputselector = $("input[name=payment][value=paypal_apm]");
|
||||
let textselector = inputselector.closest("label").find('.accordion-label-text');
|
||||
let eligibles = [];
|
||||
renderAPMs: function () {
|
||||
pretixpaypal.restore()
|
||||
let inputselector = $('input[name=payment][value=paypal_apm]')
|
||||
let textselector = inputselector.closest('label').find('.accordion-label-text')
|
||||
let eligibles = []
|
||||
|
||||
pretixpaypal.paypal.getFundingSources().forEach(function (fundingSource) {
|
||||
// Let's always skip PayPal, since it's always a dedicated funding source
|
||||
if (fundingSource === 'paypal') {
|
||||
return;
|
||||
}
|
||||
pretixpaypal.paypal.getFundingSources().forEach(function (fundingSource) {
|
||||
// Let's always skip PayPal, since it's always a dedicated funding source
|
||||
if (fundingSource === 'paypal') {
|
||||
return
|
||||
}
|
||||
|
||||
// This could also be paypal.Marks() - but they only expose images instead of cleartext...
|
||||
let button = pretixpaypal.paypal.Buttons({
|
||||
fundingSource: fundingSource
|
||||
});
|
||||
// This could also be paypal.Marks() - but they only expose images instead of cleartext...
|
||||
let button = pretixpaypal.paypal.Buttons({
|
||||
fundingSource: fundingSource
|
||||
})
|
||||
|
||||
if (button.isEligible()) {
|
||||
eligibles.push(gettext(pretixpaypal.apm_map[fundingSource] || fundingSource));
|
||||
}
|
||||
});
|
||||
if (button.isEligible()) {
|
||||
eligibles.push(gettext(pretixpaypal.apm_map[fundingSource] || fundingSource))
|
||||
}
|
||||
})
|
||||
|
||||
inputselector.attr('title', eligibles.join(', '));
|
||||
textselector.fadeOut(300, function () {
|
||||
textselector.text(eligibles.join(', '));
|
||||
textselector.fadeIn(300);
|
||||
});
|
||||
},
|
||||
inputselector.attr('title', eligibles.join(', '))
|
||||
textselector.fadeOut(300, function () {
|
||||
textselector.text(eligibles.join(', '))
|
||||
textselector.fadeIn(300)
|
||||
})
|
||||
},
|
||||
|
||||
guessLocale: function() {
|
||||
// This is a horrible hackjob and does not at all take into consideration the actual locale.
|
||||
// Instead, we only look at the language that the shop is currently being displayed in and make
|
||||
// that into a locale.
|
||||
let allowed_locales = [
|
||||
'en_US',
|
||||
'ar_DZ',
|
||||
'fr_FR',
|
||||
'es_ES',
|
||||
'zh_CN',
|
||||
'de_DE',
|
||||
'nl_NL',
|
||||
'pt_PT',
|
||||
'cs_CZ',
|
||||
'da_DK',
|
||||
'fi_FI',
|
||||
'el_GR',
|
||||
'hu_HU',
|
||||
'id_ID',
|
||||
'he_IL',
|
||||
'it_IT',
|
||||
'ja_JP',
|
||||
'ru_RU',
|
||||
'no_NO',
|
||||
'pl_PL',
|
||||
'sk_SK',
|
||||
'sv_SE',
|
||||
'th_TH',
|
||||
'tr_TR',
|
||||
]
|
||||
let lang = $("body").attr("data-locale").split('-')[0];
|
||||
return allowed_locales.find(element => element.startsWith(lang));
|
||||
}
|
||||
};
|
||||
guessLocale: function () {
|
||||
// This is a horrible hackjob and does not at all take into consideration the actual locale.
|
||||
// Instead, we only look at the language that the shop is currently being displayed in and make
|
||||
// that into a locale.
|
||||
let allowed_locales = [
|
||||
'en_US',
|
||||
'ar_DZ',
|
||||
'fr_FR',
|
||||
'es_ES',
|
||||
'zh_CN',
|
||||
'de_DE',
|
||||
'nl_NL',
|
||||
'pt_PT',
|
||||
'cs_CZ',
|
||||
'da_DK',
|
||||
'fi_FI',
|
||||
'el_GR',
|
||||
'hu_HU',
|
||||
'id_ID',
|
||||
'he_IL',
|
||||
'it_IT',
|
||||
'ja_JP',
|
||||
'ru_RU',
|
||||
'no_NO',
|
||||
'pl_PL',
|
||||
'sk_SK',
|
||||
'sv_SE',
|
||||
'th_TH',
|
||||
'tr_TR',
|
||||
]
|
||||
let lang = $('body').attr('data-locale').split('-')[0]
|
||||
return allowed_locales.find(element => element.startsWith(lang))
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// This script is always loaded if paypal is enabled as a payment method, regardless of
|
||||
// whether it is available (it could e.g. be hidden or limited to certain countries).
|
||||
// We do not want to unnecessarily load the sdk.
|
||||
// If no paypal/paypal_apm payment option is present and we are not on
|
||||
// the (APM) PayView, then we do not need the SDK.
|
||||
if (!$("input[name=payment][value^='paypal']").length && !$('#paypal-button-container').data('paypage')) {
|
||||
return
|
||||
}
|
||||
// This script is always loaded if paypal is enabled as a payment method, regardless of
|
||||
// whether it is available (it could e.g. be hidden or limited to certain countries).
|
||||
// We do not want to unnecessarily load the sdk.
|
||||
// If no paypal/paypal_apm payment option is present and we are not on
|
||||
// the (APM) PayView, then we do not need the SDK.
|
||||
if (!$('input[name=payment][value^=\'paypal\']').length && !$('#paypal-button-container').data('paypage')) {
|
||||
return
|
||||
}
|
||||
|
||||
pretixpaypal.load();
|
||||
pretixpaypal.load();
|
||||
|
||||
(async() => {
|
||||
while(!pretixpaypal.paypal)
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
pretixpaypal.ready();
|
||||
})();
|
||||
});
|
||||
(async () => {
|
||||
while (!pretixpaypal.paypal)
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
pretixpaypal.ready()
|
||||
})()
|
||||
})
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
/*globals $, Morris, gettext, django*/
|
||||
function gettext(msgid) {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid);
|
||||
}
|
||||
return msgid;
|
||||
/* globals Morris, django */
|
||||
function gettext (msgid) {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid)
|
||||
}
|
||||
return msgid
|
||||
}
|
||||
$(function () {
|
||||
$(".chart").css("height", "250px");
|
||||
new Morris.Area({
|
||||
element: 'obd_chart',
|
||||
data: JSON.parse($("#obd-data").html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
});
|
||||
new Morris.Area({
|
||||
element: 'abd_chart',
|
||||
data: JSON.parse($("#abd-data").html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Attendees (ordered)'), gettext('Attendees (paid)')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
});
|
||||
new Morris.Area({
|
||||
element: 'abt_chart',
|
||||
data: JSON.parse($("#abt-data").html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Attendees (ordered)'), gettext('Attendees (paid)')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
});
|
||||
new Morris.Area({
|
||||
element: 'rev_chart',
|
||||
data: JSON.parse($("#rev-data").html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['revenue'],
|
||||
labels: [gettext('Total revenue')],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
lineColors: ['#3b1c4a'],
|
||||
fillOpacity: 0.3,
|
||||
preUnits: $.trim($("#currency").html()) + ' '
|
||||
});
|
||||
new Morris.Bar({
|
||||
element: 'obp_chart',
|
||||
data: JSON.parse($("#obp-data").html()),
|
||||
xkey: 'item_short',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
||||
barColors: ['#3b1c4a', '#50a167'],
|
||||
hoverCallback: function (index, options, content, row) {
|
||||
console.log(content);
|
||||
var $c = $("<div>" + content + "</div>");
|
||||
var $label = $c.find(".morris-hover-row-label");
|
||||
$label.text(row.item);
|
||||
var newc = $label.get(0).outerHTML;
|
||||
$c.find('.morris-hover-point').each(function (i, r) {
|
||||
if ($.trim($(r).text().split("\n")[2]) !== "0") {
|
||||
newc += r.outerHTML;
|
||||
}
|
||||
});
|
||||
return newc;
|
||||
},
|
||||
resize: true,
|
||||
xLabelAngle: 30
|
||||
});
|
||||
});
|
||||
$('.chart').css('height', '250px')
|
||||
new Morris.Area({
|
||||
element: 'obd_chart',
|
||||
data: JSON.parse($('#obd-data').html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
})
|
||||
new Morris.Area({
|
||||
element: 'abd_chart',
|
||||
data: JSON.parse($('#abd-data').html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Attendees (ordered)'), gettext('Attendees (paid)')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
})
|
||||
new Morris.Area({
|
||||
element: 'abt_chart',
|
||||
data: JSON.parse($('#abt-data').html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Attendees (ordered)'), gettext('Attendees (paid)')],
|
||||
lineColors: ['#3b1c4a', '#50a167'],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
fillOpacity: 0.3,
|
||||
behaveLikeLine: true
|
||||
})
|
||||
new Morris.Area({
|
||||
element: 'rev_chart',
|
||||
data: JSON.parse($('#rev-data').html()),
|
||||
xkey: 'date',
|
||||
ykeys: ['revenue'],
|
||||
labels: [gettext('Total revenue')],
|
||||
smooth: false,
|
||||
resize: true,
|
||||
lineColors: ['#3b1c4a'],
|
||||
fillOpacity: 0.3,
|
||||
preUnits: $.trim($('#currency').html()) + ' '
|
||||
})
|
||||
new Morris.Bar({
|
||||
element: 'obp_chart',
|
||||
data: JSON.parse($('#obp-data').html()),
|
||||
xkey: 'item_short',
|
||||
ykeys: ['ordered', 'paid'],
|
||||
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
||||
barColors: ['#3b1c4a', '#50a167'],
|
||||
hoverCallback: function (index, options, content, row) {
|
||||
console.log(content)
|
||||
let $c = $('<div>' + content + '</div>')
|
||||
let $label = $c.find('.morris-hover-row-label')
|
||||
$label.text(row.item)
|
||||
let newc = $label.get(0).outerHTML
|
||||
$c.find('.morris-hover-point').each(function (i, r) {
|
||||
if ($.trim($(r).text().split('\n')[2]) !== '0') {
|
||||
newc += r.outerHTML
|
||||
}
|
||||
})
|
||||
return newc
|
||||
},
|
||||
resize: true,
|
||||
xLabelAngle: 30
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,435 +1,435 @@
|
||||
/*global $, stripe_pubkey, stripe_loadingmessage, gettext */
|
||||
'use strict';
|
||||
/* global stripe_pubkey, stripe_loadingmessage, gettext */
|
||||
'use strict'
|
||||
|
||||
var pretixstripe = {
|
||||
stripe: null,
|
||||
elements: null,
|
||||
card: null,
|
||||
sepa: null,
|
||||
affirm: null,
|
||||
klarna: null,
|
||||
paymentRequest: null,
|
||||
paymentRequestButton: null,
|
||||
stripe: null,
|
||||
elements: null,
|
||||
card: null,
|
||||
sepa: null,
|
||||
affirm: null,
|
||||
klarna: null,
|
||||
paymentRequest: null,
|
||||
paymentRequestButton: null,
|
||||
|
||||
'pm_request': function (method, element, kwargs = {}) {
|
||||
waitingDialog.show(gettext("Contacting Stripe …"));
|
||||
$(".stripe-errors").hide();
|
||||
pm_request: function (method, element, kwargs = {}) {
|
||||
waitingDialog.show(gettext('Contacting Stripe …'))
|
||||
$('.stripe-errors').hide()
|
||||
|
||||
pretixstripe.stripe.createPaymentMethod(method, element, kwargs).then(function (result) {
|
||||
waitingDialog.hide();
|
||||
if (result.error) {
|
||||
$(".stripe-errors").stop().hide().removeClass("sr-only");
|
||||
$(".stripe-errors").html("<div class='alert alert-danger'>" + result.error.message + "</div>");
|
||||
$(".stripe-errors").slideDown();
|
||||
} else {
|
||||
var $form = $("#stripe_" + method + "_payment_method_id").closest("form");
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$("#stripe_" + method + "_payment_method_id").val(result.paymentMethod.id);
|
||||
if (method === 'card') {
|
||||
$("#stripe_card_brand").val(result.paymentMethod.card.brand);
|
||||
$("#stripe_card_last4").val(result.paymentMethod.card.last4);
|
||||
}
|
||||
if (method === 'sepa_debit') {
|
||||
$("#stripe_sepa_debit_last4").val(result.paymentMethod.sepa_debit.last4);
|
||||
}
|
||||
// and submit
|
||||
$form.get(0).submit();
|
||||
}
|
||||
}).catch((e) => {
|
||||
waitingDialog.hide();
|
||||
$(".stripe-errors").stop().hide().removeClass("sr-only");
|
||||
$(".stripe-errors").html("<div class='alert alert-danger'>Technical error, please contact support: " + e + "</div>");
|
||||
$(".stripe-errors").slideDown();
|
||||
});
|
||||
},
|
||||
'load': function () {
|
||||
if (pretixstripe.stripe !== null) {
|
||||
return;
|
||||
}
|
||||
$('.stripe-container').closest("form").find(".checkout-button-row .btn-primary").prop("disabled", true);
|
||||
$.ajax(
|
||||
{
|
||||
url: 'https://js.stripe.com/v3/',
|
||||
dataType: 'script',
|
||||
success: function () {
|
||||
if ($.trim($("#stripe_connectedAccountId").html())) {
|
||||
pretixstripe.stripe = Stripe($.trim($("#stripe_pubkey").html()), {
|
||||
stripeAccount: $.trim($("#stripe_connectedAccountId").html()),
|
||||
locale: $.trim($("body").attr("data-locale"))
|
||||
});
|
||||
} else {
|
||||
pretixstripe.stripe = Stripe($.trim($("#stripe_pubkey").html()), {
|
||||
locale: $.trim($("body").attr("data-locale"))
|
||||
});
|
||||
}
|
||||
pretixstripe.elements = pretixstripe.stripe.elements();
|
||||
if ($.trim($("#stripe_merchantcountry").html()) !== "") {
|
||||
try {
|
||||
pretixstripe.paymentRequest = pretixstripe.stripe.paymentRequest({
|
||||
country: $("#stripe_merchantcountry").html(),
|
||||
currency: $("#stripe_card_currency").val().toLowerCase(),
|
||||
total: {
|
||||
label: gettext('Total'),
|
||||
amount: parseInt($("#stripe_card_total").val())
|
||||
},
|
||||
displayItems: [],
|
||||
requestPayerName: false,
|
||||
requestPayerEmail: false,
|
||||
requestPayerPhone: false,
|
||||
requestShipping: false,
|
||||
});
|
||||
pretixstripe.stripe.createPaymentMethod(method, element, kwargs).then(function (result) {
|
||||
waitingDialog.hide()
|
||||
if (result.error) {
|
||||
$('.stripe-errors').stop().hide().removeClass('sr-only')
|
||||
$('.stripe-errors').html('<div class=\'alert alert-danger\'>' + result.error.message + '</div>')
|
||||
$('.stripe-errors').slideDown()
|
||||
} else {
|
||||
let $form = $('#stripe_' + method + '_payment_method_id').closest('form')
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$('#stripe_' + method + '_payment_method_id').val(result.paymentMethod.id)
|
||||
if (method === 'card') {
|
||||
$('#stripe_card_brand').val(result.paymentMethod.card.brand)
|
||||
$('#stripe_card_last4').val(result.paymentMethod.card.last4)
|
||||
}
|
||||
if (method === 'sepa_debit') {
|
||||
$('#stripe_sepa_debit_last4').val(result.paymentMethod.sepa_debit.last4)
|
||||
}
|
||||
// and submit
|
||||
$form.get(0).submit()
|
||||
}
|
||||
}).catch((e) => {
|
||||
waitingDialog.hide()
|
||||
$('.stripe-errors').stop().hide().removeClass('sr-only')
|
||||
$('.stripe-errors').html('<div class=\'alert alert-danger\'>Technical error, please contact support: ' + e + '</div>')
|
||||
$('.stripe-errors').slideDown()
|
||||
})
|
||||
},
|
||||
load: function () {
|
||||
if (pretixstripe.stripe !== null) {
|
||||
return
|
||||
}
|
||||
$('.stripe-container').closest('form').find('.checkout-button-row .btn-primary').prop('disabled', true)
|
||||
$.ajax(
|
||||
{
|
||||
url: 'https://js.stripe.com/v3/',
|
||||
dataType: 'script',
|
||||
success: function () {
|
||||
if ($.trim($('#stripe_connectedAccountId').html())) {
|
||||
pretixstripe.stripe = Stripe($.trim($('#stripe_pubkey').html()), {
|
||||
stripeAccount: $.trim($('#stripe_connectedAccountId').html()),
|
||||
locale: $.trim($('body').attr('data-locale'))
|
||||
})
|
||||
} else {
|
||||
pretixstripe.stripe = Stripe($.trim($('#stripe_pubkey').html()), {
|
||||
locale: $.trim($('body').attr('data-locale'))
|
||||
})
|
||||
}
|
||||
pretixstripe.elements = pretixstripe.stripe.elements()
|
||||
if ($.trim($('#stripe_merchantcountry').html()) !== '') {
|
||||
try {
|
||||
pretixstripe.paymentRequest = pretixstripe.stripe.paymentRequest({
|
||||
country: $('#stripe_merchantcountry').html(),
|
||||
currency: $('#stripe_card_currency').val().toLowerCase(),
|
||||
total: {
|
||||
label: gettext('Total'),
|
||||
amount: parseInt($('#stripe_card_total').val())
|
||||
},
|
||||
displayItems: [],
|
||||
requestPayerName: false,
|
||||
requestPayerEmail: false,
|
||||
requestPayerPhone: false,
|
||||
requestShipping: false,
|
||||
})
|
||||
|
||||
pretixstripe.paymentRequest.on('paymentmethod', function (ev) {
|
||||
ev.complete('success');
|
||||
pretixstripe.paymentRequest.on('paymentmethod', function (ev) {
|
||||
ev.complete('success')
|
||||
|
||||
var $form = $("#stripe_card_payment_method_id").closest("form");
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$("#stripe_card_payment_method_id").val(ev.paymentMethod.id);
|
||||
$("#stripe_card_brand").val(ev.paymentMethod.card.brand);
|
||||
$("#stripe_card_last4").val(ev.paymentMethod.card.last4);
|
||||
// and submit
|
||||
$form.get(0).submit();
|
||||
});
|
||||
} catch (e) {
|
||||
pretixstripe.paymentRequest = null;
|
||||
}
|
||||
} else {
|
||||
pretixstripe.paymentRequest = null;
|
||||
}
|
||||
if ($("#stripe-card").length) {
|
||||
pretixstripe.card = pretixstripe.elements.create('card', {
|
||||
'style': {
|
||||
'base': {
|
||||
'fontFamily': '"Open Sans","OpenSans","Helvetica Neue",Helvetica,Arial,sans-serif',
|
||||
'fontSize': '14px',
|
||||
'color': '#555555',
|
||||
'lineHeight': '1.42857',
|
||||
'border': '1px solid #ccc',
|
||||
'::placeholder': {
|
||||
color: 'rgba(0,0,0,0.4)',
|
||||
},
|
||||
},
|
||||
'invalid': {
|
||||
'color': 'red',
|
||||
},
|
||||
},
|
||||
classes: {
|
||||
focus: 'is-focused',
|
||||
invalid: 'has-error',
|
||||
}
|
||||
});
|
||||
pretixstripe.card.mount("#stripe-card");
|
||||
pretixstripe.card.on('ready', function () {
|
||||
$('.stripe-container').closest("form").find(".checkout-button-row .btn-primary").prop("disabled", false);
|
||||
});
|
||||
}
|
||||
if ($("#stripe-sepa").length) {
|
||||
pretixstripe.sepa = pretixstripe.elements.create('iban', {
|
||||
'style': {
|
||||
'base': {
|
||||
'fontFamily': '"Open Sans","OpenSans","Helvetica Neue",Helvetica,Arial,sans-serif',
|
||||
'fontSize': '14px',
|
||||
'color': '#555555',
|
||||
'lineHeight': '1.42857',
|
||||
'border': '1px solid #ccc',
|
||||
'::placeholder': {
|
||||
color: 'rgba(0,0,0,0.4)',
|
||||
},
|
||||
},
|
||||
'invalid': {
|
||||
'color': 'red',
|
||||
},
|
||||
},
|
||||
supportedCountries: ['SEPA'],
|
||||
classes: {
|
||||
focus: 'is-focused',
|
||||
invalid: 'has-error',
|
||||
}
|
||||
});
|
||||
pretixstripe.sepa.on('change', function (event) {
|
||||
// List of IBAN-countries, that require the country as well as line1-property according to
|
||||
// https://stripe.com/docs/payments/sepa-debit/accept-a-payment?platform=web&ui=element#web-submit-payment
|
||||
if (['AD', 'PF', 'TF', 'GI', 'GB', 'GG', 'VA', 'IM', 'JE', 'MC', 'NC', 'BL', 'PM', 'SM', 'CH', 'WF'].indexOf(event.country) > 0) {
|
||||
$("#stripe_sepa_debit_country").prop('checked', true);
|
||||
$("#stripe_sepa_debit_country").change();
|
||||
} else {
|
||||
$("#stripe_sepa_debit_country").prop('checked', false);
|
||||
$("#stripe_sepa_debit_country").change();
|
||||
}
|
||||
if (event.bankName) {
|
||||
$("#stripe_sepa_debit_bank").val(event.bankName);
|
||||
}
|
||||
});
|
||||
pretixstripe.sepa.mount("#stripe-sepa");
|
||||
pretixstripe.sepa.on('ready', function () {
|
||||
$('.stripe-container').closest("form").find(".checkout-button-row .btn-primary").prop("disabled", false);
|
||||
});
|
||||
}
|
||||
if ($("#stripe-affirm").length) {
|
||||
pretixstripe.affirm = pretixstripe.elements.create('affirmMessage', {
|
||||
'amount': parseInt($("#stripe_affirm_total").val()),
|
||||
'currency': $("#stripe_affirm_currency").val(),
|
||||
});
|
||||
let $form = $('#stripe_card_payment_method_id').closest('form')
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$('#stripe_card_payment_method_id').val(ev.paymentMethod.id)
|
||||
$('#stripe_card_brand').val(ev.paymentMethod.card.brand)
|
||||
$('#stripe_card_last4').val(ev.paymentMethod.card.last4)
|
||||
// and submit
|
||||
$form.get(0).submit()
|
||||
})
|
||||
} catch (e) {
|
||||
pretixstripe.paymentRequest = null
|
||||
}
|
||||
} else {
|
||||
pretixstripe.paymentRequest = null
|
||||
}
|
||||
if ($('#stripe-card').length) {
|
||||
pretixstripe.card = pretixstripe.elements.create('card', {
|
||||
style: {
|
||||
base: {
|
||||
fontFamily: '"Open Sans","OpenSans","Helvetica Neue",Helvetica,Arial,sans-serif',
|
||||
fontSize: '14px',
|
||||
color: '#555555',
|
||||
lineHeight: '1.42857',
|
||||
border: '1px solid #ccc',
|
||||
'::placeholder': {
|
||||
color: 'rgba(0,0,0,0.4)',
|
||||
},
|
||||
},
|
||||
invalid: {
|
||||
color: 'red',
|
||||
},
|
||||
},
|
||||
classes: {
|
||||
focus: 'is-focused',
|
||||
invalid: 'has-error',
|
||||
}
|
||||
})
|
||||
pretixstripe.card.mount('#stripe-card')
|
||||
pretixstripe.card.on('ready', function () {
|
||||
$('.stripe-container').closest('form').find('.checkout-button-row .btn-primary').prop('disabled', false)
|
||||
})
|
||||
}
|
||||
if ($('#stripe-sepa').length) {
|
||||
pretixstripe.sepa = pretixstripe.elements.create('iban', {
|
||||
style: {
|
||||
base: {
|
||||
fontFamily: '"Open Sans","OpenSans","Helvetica Neue",Helvetica,Arial,sans-serif',
|
||||
fontSize: '14px',
|
||||
color: '#555555',
|
||||
lineHeight: '1.42857',
|
||||
border: '1px solid #ccc',
|
||||
'::placeholder': {
|
||||
color: 'rgba(0,0,0,0.4)',
|
||||
},
|
||||
},
|
||||
invalid: {
|
||||
color: 'red',
|
||||
},
|
||||
},
|
||||
supportedCountries: ['SEPA'],
|
||||
classes: {
|
||||
focus: 'is-focused',
|
||||
invalid: 'has-error',
|
||||
}
|
||||
})
|
||||
pretixstripe.sepa.on('change', function (event) {
|
||||
// List of IBAN-countries, that require the country as well as line1-property according to
|
||||
// https://stripe.com/docs/payments/sepa-debit/accept-a-payment?platform=web&ui=element#web-submit-payment
|
||||
if (['AD', 'PF', 'TF', 'GI', 'GB', 'GG', 'VA', 'IM', 'JE', 'MC', 'NC', 'BL', 'PM', 'SM', 'CH', 'WF'].indexOf(event.country) > 0) {
|
||||
$('#stripe_sepa_debit_country').prop('checked', true)
|
||||
$('#stripe_sepa_debit_country').change()
|
||||
} else {
|
||||
$('#stripe_sepa_debit_country').prop('checked', false)
|
||||
$('#stripe_sepa_debit_country').change()
|
||||
}
|
||||
if (event.bankName) {
|
||||
$('#stripe_sepa_debit_bank').val(event.bankName)
|
||||
}
|
||||
})
|
||||
pretixstripe.sepa.mount('#stripe-sepa')
|
||||
pretixstripe.sepa.on('ready', function () {
|
||||
$('.stripe-container').closest('form').find('.checkout-button-row .btn-primary').prop('disabled', false)
|
||||
})
|
||||
}
|
||||
if ($('#stripe-affirm').length) {
|
||||
pretixstripe.affirm = pretixstripe.elements.create('affirmMessage', {
|
||||
amount: parseInt($('#stripe_affirm_total').val()),
|
||||
currency: $('#stripe_affirm_currency').val(),
|
||||
})
|
||||
|
||||
pretixstripe.affirm.mount('#stripe-affirm');
|
||||
}
|
||||
if ($("#stripe-klarna").length) {
|
||||
try {
|
||||
pretixstripe.klarna = pretixstripe.elements.create('paymentMethodMessaging', {
|
||||
'amount': parseInt($("#stripe_klarna_total").val()),
|
||||
'currency': $("#stripe_klarna_currency").val(),
|
||||
'countryCode': $("#stripe_klarna_country").val(),
|
||||
'paymentMethodTypes': ['klarna'],
|
||||
});
|
||||
pretixstripe.affirm.mount('#stripe-affirm')
|
||||
}
|
||||
if ($('#stripe-klarna').length) {
|
||||
try {
|
||||
pretixstripe.klarna = pretixstripe.elements.create('paymentMethodMessaging', {
|
||||
amount: parseInt($('#stripe_klarna_total').val()),
|
||||
currency: $('#stripe_klarna_currency').val(),
|
||||
countryCode: $('#stripe_klarna_country').val(),
|
||||
paymentMethodTypes: ['klarna'],
|
||||
})
|
||||
|
||||
pretixstripe.klarna.mount('#stripe-klarna');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
$("#stripe-klarna").html("<div class='alert alert-danger'>Technical error, please contact support: " + e + "</div>");
|
||||
}
|
||||
}
|
||||
if ($("#stripe-payment-request-button").length && pretixstripe.paymentRequest != null) {
|
||||
pretixstripe.paymentRequestButton = pretixstripe.elements.create('paymentRequestButton', {
|
||||
paymentRequest: pretixstripe.paymentRequest,
|
||||
});
|
||||
pretixstripe.klarna.mount('#stripe-klarna')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
$('#stripe-klarna').html('<div class=\'alert alert-danger\'>Technical error, please contact support: ' + e + '</div>')
|
||||
}
|
||||
}
|
||||
if ($('#stripe-payment-request-button').length && pretixstripe.paymentRequest != null) {
|
||||
pretixstripe.paymentRequestButton = pretixstripe.elements.create('paymentRequestButton', {
|
||||
paymentRequest: pretixstripe.paymentRequest,
|
||||
})
|
||||
|
||||
pretixstripe.paymentRequest.canMakePayment().then(function (result) {
|
||||
if (result) {
|
||||
pretixstripe.paymentRequestButton.mount('#stripe-payment-request-button');
|
||||
$('#stripe-card-elements .stripe-or').removeClass("hidden");
|
||||
$('#stripe-payment-request-button').parent().removeClass("hidden");
|
||||
} else {
|
||||
$('#stripe-payment-request-button').hide();
|
||||
document.getElementById('stripe-payment-request-button').style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
'withStripe': function (callback) {
|
||||
$.ajax({
|
||||
url: 'https://js.stripe.com/v3/',
|
||||
dataType: 'script',
|
||||
success: function () {
|
||||
if ($.trim($("#stripe_connectedAccountId").html())) {
|
||||
pretixstripe.stripe = Stripe($.trim($("#stripe_pubkey").html()), {
|
||||
stripeAccount: $.trim($("#stripe_connectedAccountId").html()),
|
||||
locale: $.trim($("body").attr("data-locale"))
|
||||
});
|
||||
} else {
|
||||
pretixstripe.stripe = Stripe($.trim($("#stripe_pubkey").html()), {
|
||||
locale: $.trim($("body").attr("data-locale"))
|
||||
});
|
||||
}
|
||||
callback();
|
||||
}
|
||||
});
|
||||
},
|
||||
'handleAlipayAction': function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.confirmAlipayPayment(
|
||||
payment_intent_client_secret,
|
||||
{
|
||||
return_url: window.location.href
|
||||
}
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide();
|
||||
$(".stripe-errors").stop().hide().removeClass("sr-only");
|
||||
$(".stripe-errors").html("<div class='alert alert-danger'>Technical error, please contact support: " + result.error.message + "</div>");
|
||||
$(".stripe-errors").slideDown();
|
||||
} else {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
'handleWechatAction': function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.confirmWechatPayPayment(
|
||||
payment_intent_client_secret,
|
||||
{
|
||||
payment_method_options: {
|
||||
wechat_pay: {
|
||||
client: 'web',
|
||||
},
|
||||
},
|
||||
}
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide();
|
||||
$(".stripe-errors").stop().hide().removeClass("sr-only");
|
||||
$(".stripe-errors").html("<div class='alert alert-danger'>Technical error, please contact support: " + result.error.message + "</div>");
|
||||
$(".stripe-errors").slideDown();
|
||||
} else {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
'handleCardAction': function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.handleCardAction(
|
||||
payment_intent_client_secret
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide();
|
||||
$(".stripe-errors").stop().hide().removeClass("sr-only");
|
||||
$(".stripe-errors").html("<div class='alert alert-danger'>Technical error, please contact support: " + result.error.message + "</div>");
|
||||
$(".stripe-errors").slideDown();
|
||||
} else {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
'handlePaymentRedirectAction': function (payment_intent_next_action_redirect_url) {
|
||||
waitingDialog.show(gettext("Contacting your bank …"));
|
||||
pretixstripe.paymentRequest.canMakePayment().then(function (result) {
|
||||
if (result) {
|
||||
pretixstripe.paymentRequestButton.mount('#stripe-payment-request-button')
|
||||
$('#stripe-card-elements .stripe-or').removeClass('hidden')
|
||||
$('#stripe-payment-request-button').parent().removeClass('hidden')
|
||||
} else {
|
||||
$('#stripe-payment-request-button').hide()
|
||||
document.getElementById('stripe-payment-request-button').style.display = 'none'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
withStripe: function (callback) {
|
||||
$.ajax({
|
||||
url: 'https://js.stripe.com/v3/',
|
||||
dataType: 'script',
|
||||
success: function () {
|
||||
if ($.trim($('#stripe_connectedAccountId').html())) {
|
||||
pretixstripe.stripe = Stripe($.trim($('#stripe_pubkey').html()), {
|
||||
stripeAccount: $.trim($('#stripe_connectedAccountId').html()),
|
||||
locale: $.trim($('body').attr('data-locale'))
|
||||
})
|
||||
} else {
|
||||
pretixstripe.stripe = Stripe($.trim($('#stripe_pubkey').html()), {
|
||||
locale: $.trim($('body').attr('data-locale'))
|
||||
})
|
||||
}
|
||||
callback()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleAlipayAction: function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.confirmAlipayPayment(
|
||||
payment_intent_client_secret,
|
||||
{
|
||||
return_url: window.location.href
|
||||
}
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide()
|
||||
$('.stripe-errors').stop().hide().removeClass('sr-only')
|
||||
$('.stripe-errors').html('<div class=\'alert alert-danger\'>Technical error, please contact support: ' + result.error.message + '</div>')
|
||||
$('.stripe-errors').slideDown()
|
||||
} else {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleWechatAction: function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.confirmWechatPayPayment(
|
||||
payment_intent_client_secret,
|
||||
{
|
||||
payment_method_options: {
|
||||
wechat_pay: {
|
||||
client: 'web',
|
||||
},
|
||||
},
|
||||
}
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide()
|
||||
$('.stripe-errors').stop().hide().removeClass('sr-only')
|
||||
$('.stripe-errors').html('<div class=\'alert alert-danger\'>Technical error, please contact support: ' + result.error.message + '</div>')
|
||||
$('.stripe-errors').slideDown()
|
||||
} else {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleCardAction: function (payment_intent_client_secret) {
|
||||
pretixstripe.withStripe(function () {
|
||||
pretixstripe.stripe.handleCardAction(
|
||||
payment_intent_client_secret
|
||||
).then(function (result) {
|
||||
if (result.error) {
|
||||
waitingDialog.hide()
|
||||
$('.stripe-errors').stop().hide().removeClass('sr-only')
|
||||
$('.stripe-errors').html('<div class=\'alert alert-danger\'>Technical error, please contact support: ' + result.error.message + '</div>')
|
||||
$('.stripe-errors').slideDown()
|
||||
} else {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handlePaymentRedirectAction: function (payment_intent_next_action_redirect_url) {
|
||||
waitingDialog.show(gettext('Contacting your bank …'))
|
||||
|
||||
let payment_intent_redirect_action_handling = $.trim($("#stripe_payment_intent_redirect_action_handling").html());
|
||||
if (payment_intent_redirect_action_handling === 'iframe') {
|
||||
let iframe = document.createElement('iframe');
|
||||
iframe.src = payment_intent_next_action_redirect_url;
|
||||
iframe.className = 'embed-responsive-item';
|
||||
$('#scacontainer').append(iframe);
|
||||
$('#scacontainer iframe').on("load", function () {
|
||||
waitingDialog.hide();
|
||||
});
|
||||
} else if (payment_intent_redirect_action_handling === 'redirect') {
|
||||
window.location.href = payment_intent_next_action_redirect_url;
|
||||
}
|
||||
}
|
||||
};
|
||||
let payment_intent_redirect_action_handling = $.trim($('#stripe_payment_intent_redirect_action_handling').html())
|
||||
if (payment_intent_redirect_action_handling === 'iframe') {
|
||||
let iframe = document.createElement('iframe')
|
||||
iframe.src = payment_intent_next_action_redirect_url
|
||||
iframe.className = 'embed-responsive-item'
|
||||
$('#scacontainer').append(iframe)
|
||||
$('#scacontainer iframe').on('load', function () {
|
||||
waitingDialog.hide()
|
||||
})
|
||||
} else if (payment_intent_redirect_action_handling === 'redirect') {
|
||||
window.location.href = payment_intent_next_action_redirect_url
|
||||
}
|
||||
}
|
||||
}
|
||||
$(function () {
|
||||
if ($("#stripe_payment_intent_SCA_status").length) {
|
||||
let payment_intent_redirect_action_handling = $.trim($("#stripe_payment_intent_redirect_action_handling").html());
|
||||
let order_status = $.trim($("#order_status").html());
|
||||
let order_url = $.trim($("#order_url").html())
|
||||
if ($('#stripe_payment_intent_SCA_status').length) {
|
||||
let payment_intent_redirect_action_handling = $.trim($('#stripe_payment_intent_redirect_action_handling').html())
|
||||
let order_status = $.trim($('#order_status').html())
|
||||
let order_url = $.trim($('#order_url').html())
|
||||
|
||||
if (payment_intent_redirect_action_handling === 'iframe') {
|
||||
window.parent.postMessage('3DS-authentication-complete.' + order_status, '*');
|
||||
return;
|
||||
} else if (payment_intent_redirect_action_handling === 'redirect') {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
if (payment_intent_redirect_action_handling === 'iframe') {
|
||||
window.parent.postMessage('3DS-authentication-complete.' + order_status, '*')
|
||||
return
|
||||
} else if (payment_intent_redirect_action_handling === 'redirect') {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
|
||||
if (order_status === 'p') {
|
||||
window.location.href = order_url + '?paid=yes';
|
||||
} else {
|
||||
window.location.href = order_url;
|
||||
}
|
||||
}
|
||||
} else if ($("#stripe_payment_intent_next_action_redirect_url").length) {
|
||||
let payment_intent_next_action_redirect_url = JSON.parse($("#stripe_payment_intent_next_action_redirect_url").html());
|
||||
pretixstripe.handlePaymentRedirectAction(payment_intent_next_action_redirect_url);
|
||||
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "promptpay_display_qr_code") {
|
||||
waitingDialog.hide();
|
||||
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "wechat_pay_display_qr_code") {
|
||||
let payment_intent_client_secret = $.trim($("#stripe_payment_intent_client_secret").html());
|
||||
pretixstripe.handleWechatAction(payment_intent_client_secret);
|
||||
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "alipay_handle_redirect") {
|
||||
let payment_intent_client_secret = $.trim($("#stripe_payment_intent_client_secret").html());
|
||||
pretixstripe.handleAlipayAction(payment_intent_client_secret);
|
||||
} else if ($("#stripe_payment_intent_client_secret").length) {
|
||||
let payment_intent_client_secret = $.trim($("#stripe_payment_intent_client_secret").html());
|
||||
pretixstripe.handleCardAction(payment_intent_client_secret);
|
||||
}
|
||||
if (order_status === 'p') {
|
||||
window.location.href = order_url + '?paid=yes'
|
||||
} else {
|
||||
window.location.href = order_url
|
||||
}
|
||||
}
|
||||
} else if ($('#stripe_payment_intent_next_action_redirect_url').length) {
|
||||
let payment_intent_next_action_redirect_url = JSON.parse($('#stripe_payment_intent_next_action_redirect_url').html())
|
||||
pretixstripe.handlePaymentRedirectAction(payment_intent_next_action_redirect_url)
|
||||
} else if ($.trim($('#stripe_payment_intent_action_type').html()) === 'promptpay_display_qr_code') {
|
||||
waitingDialog.hide()
|
||||
} else if ($.trim($('#stripe_payment_intent_action_type').html()) === 'wechat_pay_display_qr_code') {
|
||||
let payment_intent_client_secret = $.trim($('#stripe_payment_intent_client_secret').html())
|
||||
pretixstripe.handleWechatAction(payment_intent_client_secret)
|
||||
} else if ($.trim($('#stripe_payment_intent_action_type').html()) === 'alipay_handle_redirect') {
|
||||
let payment_intent_client_secret = $.trim($('#stripe_payment_intent_client_secret').html())
|
||||
pretixstripe.handleAlipayAction(payment_intent_client_secret)
|
||||
} else if ($('#stripe_payment_intent_client_secret').length) {
|
||||
let payment_intent_client_secret = $.trim($('#stripe_payment_intent_client_secret').html())
|
||||
pretixstripe.handleCardAction(payment_intent_client_secret)
|
||||
}
|
||||
|
||||
$(window).on("message onmessage", function (e) {
|
||||
if (typeof e.originalEvent.data === "string" && e.originalEvent.data.startsWith('3DS-authentication-complete.')) {
|
||||
waitingDialog.show(gettext("Confirming your payment …"));
|
||||
$('#scacontainer').hide();
|
||||
$('#continuebutton').removeClass('hidden');
|
||||
$(window).on('message onmessage', function (e) {
|
||||
if (typeof e.originalEvent.data === 'string' && e.originalEvent.data.startsWith('3DS-authentication-complete.')) {
|
||||
waitingDialog.show(gettext('Confirming your payment …'))
|
||||
$('#scacontainer').hide()
|
||||
$('#continuebutton').removeClass('hidden')
|
||||
|
||||
if (e.originalEvent.data.split('.')[1] == 'p') {
|
||||
window.location.href = $('#continuebutton').attr('href') + '?paid=yes';
|
||||
} else {
|
||||
window.location.href = $('#continuebutton').attr('href');
|
||||
}
|
||||
}
|
||||
});
|
||||
if (e.originalEvent.data.split('.')[1] == 'p') {
|
||||
window.location.href = $('#continuebutton').attr('href') + '?paid=yes'
|
||||
} else {
|
||||
window.location.href = $('#continuebutton').attr('href')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!$(".stripe-container").length)
|
||||
return;
|
||||
if (!$('.stripe-container').length)
|
||||
return
|
||||
|
||||
if (
|
||||
$("input[name=payment][value=stripe]").is(':checked')
|
||||
|| $("input[name=payment][value=stripe_sepa_debit]").is(':checked')
|
||||
|| $("input[name=payment][value=stripe_affirm]").is(':checked')
|
||||
|| $("input[name=payment][value=stripe_klarna]").is(':checked')
|
||||
|| $(".payment-redo-form").length) {
|
||||
pretixstripe.load();
|
||||
} else {
|
||||
$("input[name=payment]").change(function () {
|
||||
if (['stripe', 'stripe_sepa_debit', 'stripe_affirm', 'stripe_klarna'].indexOf($(this).val()) > -1) {
|
||||
pretixstripe.load();
|
||||
}
|
||||
})
|
||||
}
|
||||
if (
|
||||
$('input[name=payment][value=stripe]').is(':checked')
|
||||
|| $('input[name=payment][value=stripe_sepa_debit]').is(':checked')
|
||||
|| $('input[name=payment][value=stripe_affirm]').is(':checked')
|
||||
|| $('input[name=payment][value=stripe_klarna]').is(':checked')
|
||||
|| $('.payment-redo-form').length) {
|
||||
pretixstripe.load()
|
||||
} else {
|
||||
$('input[name=payment]').change(function () {
|
||||
if (['stripe', 'stripe_sepa_debit', 'stripe_affirm', 'stripe_klarna'].indexOf($(this).val()) > -1) {
|
||||
pretixstripe.load()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$("#stripe_other_card").click(
|
||||
function (e) {
|
||||
$("#stripe_card_payment_method_id").val("");
|
||||
$("#stripe-current-card").slideUp();
|
||||
$("#stripe-card-elements").slideDown();
|
||||
$('#stripe_other_card').click(
|
||||
function (e) {
|
||||
$('#stripe_card_payment_method_id').val('')
|
||||
$('#stripe-current-card').slideUp()
|
||||
$('#stripe-card-elements').slideDown()
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
e.preventDefault()
|
||||
return false
|
||||
}
|
||||
)
|
||||
|
||||
if ($("#stripe-current-card").length) {
|
||||
$("#stripe-card-elements").hide();
|
||||
}
|
||||
if ($('#stripe-current-card').length) {
|
||||
$('#stripe-card-elements').hide()
|
||||
}
|
||||
|
||||
$("#stripe_other_account").click(
|
||||
function (e) {
|
||||
$("#stripe_sepa_debit_payment_method_id").val("");
|
||||
$("#stripe-current-account").slideUp();
|
||||
// We're using a css-selector here instead of the id-selector,
|
||||
// as we're hiding Stripe Elements *and* Django form fields
|
||||
$('.stripe-sepa_debit-form').slideDown();
|
||||
$('#stripe_other_account').click(
|
||||
function (e) {
|
||||
$('#stripe_sepa_debit_payment_method_id').val('')
|
||||
$('#stripe-current-account').slideUp()
|
||||
// We're using a css-selector here instead of the id-selector,
|
||||
// as we're hiding Stripe Elements *and* Django form fields
|
||||
$('.stripe-sepa_debit-form').slideDown()
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
e.preventDefault()
|
||||
return false
|
||||
}
|
||||
)
|
||||
|
||||
if ($("#stripe-current-account").length) {
|
||||
// We're using a css-selector here instead of the id-selector,
|
||||
// as we're hiding Stripe Elements *and* Django form fields
|
||||
$('.stripe-sepa_debit-form').hide();
|
||||
}
|
||||
if ($('#stripe-current-account').length) {
|
||||
// We're using a css-selector here instead of the id-selector,
|
||||
// as we're hiding Stripe Elements *and* Django form fields
|
||||
$('.stripe-sepa_debit-form').hide()
|
||||
}
|
||||
|
||||
$('.stripe-container').closest("form").submit(
|
||||
function () {
|
||||
if ($("input[name=card_new]").length && !$("input[name=card_new]").prop('checked')) {
|
||||
return null;
|
||||
}
|
||||
if (($("input[name=payment][value=stripe]").prop('checked') || $("input[name=payment][type=radio]").length === 0)
|
||||
&& $("#stripe_card_payment_method_id").val() == "") {
|
||||
pretixstripe.pm_request('card', pretixstripe.card);
|
||||
return false;
|
||||
}
|
||||
$('.stripe-container').closest('form').submit(
|
||||
function () {
|
||||
if ($('input[name=card_new]').length && !$('input[name=card_new]').prop('checked')) {
|
||||
return null
|
||||
}
|
||||
if (($('input[name=payment][value=stripe]').prop('checked') || $('input[name=payment][type=radio]').length === 0)
|
||||
&& $('#stripe_card_payment_method_id').val() == '') {
|
||||
pretixstripe.pm_request('card', pretixstripe.card)
|
||||
return false
|
||||
}
|
||||
|
||||
if (($("input[name=payment][value=stripe_sepa_debit]").prop('checked')) && $("#stripe_sepa_debit_payment_method_id").val() == "") {
|
||||
pretixstripe.pm_request('sepa_debit', pretixstripe.sepa, {
|
||||
billing_details: {
|
||||
name: $("#id_payment_stripe_sepa_debit-accountname").val(),
|
||||
email: $("#stripe_sepa_debit_email").val(),
|
||||
address: {
|
||||
line1: $("#id_payment_stripe_sepa_debit-line1").val(),
|
||||
postal_code: $("#id_payment_stripe_sepa_debit-postal_code").val(),
|
||||
city: $("#id_payment_stripe_sepa_debit-city").val(),
|
||||
country: $("#id_payment_stripe_sepa_debit-country").val(),
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
if (($('input[name=payment][value=stripe_sepa_debit]').prop('checked')) && $('#stripe_sepa_debit_payment_method_id').val() == '') {
|
||||
pretixstripe.pm_request('sepa_debit', pretixstripe.sepa, {
|
||||
billing_details: {
|
||||
name: $('#id_payment_stripe_sepa_debit-accountname').val(),
|
||||
email: $('#stripe_sepa_debit_email').val(),
|
||||
address: {
|
||||
line1: $('#id_payment_stripe_sepa_debit-line1').val(),
|
||||
postal_code: $('#id_payment_stripe_sepa_debit-postal_code').val(),
|
||||
city: $('#id_payment_stripe_sepa_debit-city').val(),
|
||||
country: $('#id_payment_stripe_sepa_debit-country').val(),
|
||||
}
|
||||
}
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user