1import { m as modal } from './default-BKfytsTg.js'; 2import { t as tempStore, q as quotations } from './main-module-Dg7u5i1g.js'; 3import { r as reformat } from './reformat-CJwysHiu.js'; 4import { S as Swal } from './sweetalert2.esm.all-Cmp6ZwOu.js'; 5import { h as handlePaymentReturn, P as PAYMENT_RETURN_KEY, s as serializePayment } from './payment-return-DVBXMeMS.js'; 6import './loading-CnaT4-R9.js'; 7 8class topupConfirm extends modal{constructor(){super();this.modalElement=document.querySelector(".js-modal[data-modal='topup-confirm']");this.openModals=document.querySelectorAll(".js-modal-open[data-modal='topup-confirm']");this.closeModals=document.querySelectorAll(".js-modal-close[data-modal='topup-confirm']");this.title='';this.balanceIcon=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-topupConfirm-balance-icon');this.balanceAmount=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-topupConfirm-amount-selected');this.balanceExtra=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-topupConfirm-extra');this.balanceExtraAmount=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-topupConfirm-extra-amount');this.balanceEuros=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-topup-euros');this.price=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-price');this.vat=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-vat');this.transactionCosts=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-transaction-costs');this.totalPrice=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-total-price');this.payButton=document.querySelector('.js-modal[data-modal=\'topup-confirm\'] .js-pay');}async init(){super.init();this.initEventListeners();}initEventListeners(){super.initEventListeners();document.addEventListener('openTopupConfirmModal',()=>{this.open();});handlePaymentReturn();this.payButton.addEventListener('click',e=>{e.preventDefault();this.pay();});}open(modal=this.modalElement){const quotation=tempStore.quotation.quotation_line[0];const freeQuotation=tempStore.quotation.quotation_line[1]?tempStore.quotation.quotation_line[1]:{quantity:0,unit_price_in_cents:0};const amount=quotation.quantity;const freeAmount=freeQuotation.quantity;const worth=(quotation.quantity*quotation.unit_price_in_cents+freeQuotation.quantity*freeQuotation.unit_price_in_cents)/100;const price=tempStore.quotation.subtotal_price_in_cents/100;const vat=tempStore.quotation.vat/100;const transaction_fee=tempStore.quotation.transaction_fee/100;const total=price+transaction_fee+vat;this.title=reformat.escape(tempStore.selectedPayment.name);this.balanceIcon.innerHTML=`<img src="${tempStore.selectedPayment.icon}" alt="${tempStore.selectedPayment.name} icon">`;this.balanceAmount.innerHTML=amount;if(freeAmount>0){this.balanceExtra.style.display='block';this.balanceExtraAmount.innerHTML=freeAmount;}else {this.balanceExtra.style.display='none';}this.balanceEuros.innerHTML=worth.toFixed(2);this.price.innerHTML=price.toFixed(2);this.vat.innerHTML=vat.toFixed(2);this.transactionCosts.innerHTML=transaction_fee.toFixed(2);this.totalPrice.innerHTML=total.toFixed(2);super.open(modal);}async pay(){this.loading();if(tempStore.topupNeedsRefresh&&tempStore.topupResubscribe){const newQuotation=await tempStore.topupResubscribe();if(newQuotation!==null&&newQuotation!==void 0&&newQuotation.id){tempStore.quotation=newQuotation;tempStore.topupNeedsRefresh=false;}else {Swal.fire({icon:'error',text:'Er is iets misgegaan, probeer het later opnieuw of neem contact met ons op.'});this.doneLoading();return;}}const quotationId=tempStore.quotation.id;let addedAmount=0;tempStore.quotation.quotation_line.forEach(quotation=>{addedAmount+=quotation.quantity;});const newAmount=tempStore.selectedPayment.profileWallet.moves+addedAmount;const returnUrl=tempStore.currentUrl+'?payment_return=1';const quotationData={payment_type:tempStore.quotation.payment_types[0].slug,redirect_url:returnUrl};try{const payCall=await quotations.pay(quotationId,quotationData);if(payCall['checkout_url']){var _tempStore$purchaseDa,_tempStore$selectedPa,_tempStore$pageData,_tempStore$profiles;sessionStorage.setItem(PAYMENT_RETURN_KEY,JSON.stringify({type:'topup',quotationId,quotation:tempStore.quotation,selectedPayment:serializePayment(tempStore.selectedPayment),currentUrl:tempStore.currentUrl,addedAmount,newAmount,walletName:tempStore.selectedPayment.name,returnToPaymentOptions:!!tempStore.purchaseData,purchaseData:(_tempStore$purchaseDa=tempStore.purchaseData)!==null&&_tempStore$purchaseDa!==void 0?_tempStore$purchaseDa:null,selectedParticipants:(_tempStore$selectedPa=tempStore.selectedParticipants)!==null&&_tempStore$selectedPa!==void 0?_tempStore$selectedPa:[],pageData:(_tempStore$pageData=tempStore.pageData)!==null&&_tempStore$pageData!==void 0?_tempStore$pageData:null,profiles:(_tempStore$profiles=tempStore.profiles)!==null&&_tempStore$profiles!==void 0?_tempStore$profiles:null}));window.location.href=payCall.checkout_url;}else {console.error('Something went wrong',payCall);Swal.fire({icon:"error",text:"Er is iets misgegaan. Probeer het later opnieuw of neem contact met ons op."});this.doneLoading();}}catch(error){console.error(error);Swal.fire({icon:"error",text:"Er is iets misgegaan. Probeer het later opnieuw of neem contact met ons op."});this.doneLoading();}}}const topupConfirmModal=new topupConfirm();
8(function(){topupConfirmModal.init();})(); 9 10export { topupConfirmModal };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.