/**
* NOTICE OF LICENSE
*
* This source file is subject to the Software License Agreement
* that is bundled with this package in the file LICENSE.txt.
*
* @author Peter Sliacky (Zelarg)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/** Important - change this:
* in modules/pm_subscription/models/Dispatcher/MainCase.php, in method includeAssetsOfPaymentModules():
$isOrderController = $this->context->controller instanceof OrderController || $this->context->controller instanceof OrderOpcController || $this->context->controller->page_name == "module-thecheckout-order";
*/
checkoutPaymentParser.pm_subscription_popup = {
on_ready: function() {
if ($('[data-module-name^="pm_subscription"]').length) {
$('input[name=payment-option]:not([data-module-name^="pm_subscription"]').each(function( index ) {
if ($(this).data('module-name') != 'free_order') {
var paymentOptionID = $(this).attr('id');
$('#' + paymentOptionID + '-container').parent().remove();
$('#' + paymentOptionID + '-additional-information').remove();
$('#payment-option-' + paymentOptionID + '-container').remove();
$('#pay-with-payment-option-' + paymentOptionID + '-form').remove();
} else {
// Update action of free_order module
var paymentOptionID = $(this).attr('id');
$('#pay-with-' + paymentOptionID + '-form form').attr('action', pm_subscription.validationURL);
}
});
$('input[name=payment-option][data-module-name^="pm_subscription"]').prop('checked', true);
}
setTimeout(function () {
// Load only when stripe hosted fields are not initialized yet
if (!$('#sub-stripe-card-number.card-element').length) {
$.getScript(tcModuleBaseUrl + '/../pm_subscription/views/js/front/payments.js');
}
}, 300)
},
all_hooks_content: function (content) {
},
container: function(element) {
var stripe_base_url = '';
if ('undefined' !== typeof prestashop && 'undefined' !== prestashop.urls && 'undefined' !== prestashop.urls.base_url) {
stripe_base_url = prestashop.urls.base_url;
}
// element.find('label').append('
');
// Create additional information block, informing user that payment will be processed after confirmation
var paymentOptionId = element.attr('id').match(/payment-option-\d+/);
if (paymentOptionId && 'undefined' !== typeof paymentOptionId[0]) {
paymentOptionId = paymentOptionId[0];
element.after('