(function(){ let req = "../../core/php/request.php"; if(mypage=="index"){ req = "../../core/php/request.php"; } const REQUEST_URL = req; let data = { retrieve_data_for_update: true }; const LOADER_REMOVE_WAIT = 0; const LOADER_ID = "afs-main-loader-screen"; document.body.insertAdjacentHTML("afterbegin", application_loader_screen_html()); $.post(REQUEST_URL,{ get_html_client_templates:true, path: "portal/user/html" },function(clientHtmlTemplatesStr){ $.post(REQUEST_URL, data, function(resp){ afsconfig = JSON.parse(resp); let app = new ApplicationContextManager(); app.extra.config = AFS_SCHEMA_DESCRIPTION_INTEGRATION(afsconfig); app.extra.config.html = JSON.parse(clientHtmlTemplatesStr); app.extra.config.afsanalytics = new AFSAnalytics(REQUEST_URL, app);; app.extra.pay = afsconfig.configurations.payments; app.extra.payments = new AFSPayments(app); app.extra.views = {}; app.extra.payments.service.createPaypalInstance(); app.extra.payments.service.paypal().setupLink({ params: "components=buttons,hosted-fields", // default log: true, callback: function(isPaypalLoaded){ console.log("isPaypalLoaded: " + isPaypalLoaded); requirejs.config({ baseUrl: './js/pages/' }); let routes = [mypage]; require(routes, function(_route_func){ setTimeout(() => { $("#"+LOADER_ID).remove(); _route_func(app); run(app); },LOADER_REMOVE_WAIT); }); } }); function run(app){ $('.log_out_link').on('click',function(e){ e.preventDefault(); window.location.href = app.extra.config.managed_domain.Address + "/portal/user/logout.php"; }); } window.gl_process_payment_donation = gl_process_payment_donation; function gl_process_payment_donation(paypalContainerId,amountId,app){ afspayments.service.paypal().setupCheckout({ container_id: paypalContainerId, options: { price: document.getElementById(amountId).innerHTML, appendNow: true, paypal_error_message: "Sorry, your transaction could not be processed, please try again.", showPaypalButton: true, showPaypalForm: true, billingAddressEnabled: false, billingAddressNameEnabled: false, onSubmit: { showButton: true, id: "submit", className: "paypal-donate-btn", label: "Donate", } }, button_onApprove_callback: function(){ const myModalAlternative = new bootstrap.Modal('#myModal', {}); myModalAlternative.hide(); }, button_onClick_callback: function(){ // dollar-amount let textObj = document.getElementById("dollar-amount"); let amount = app.utils.moneyFormat(textObj); if(amount==undefined || amount==""){ amount = "5.00"; } let floatAmount = parseFloat(amount); if(floatAmount < 0.5){ amount = "1.00"; } // card-name let name_obj = document.getElementById("card-name"); let name = app.utils.moneyFormat(name_obj); // card-name let emailObj = document.getElementById("card-email"); let email = app.utils.moneyFormat(emailObj); return {amount:amount,email:email,name:name}; }, /** * Called when the order is created. You should retrieve amount * then validate amount return. If the amount is validate * successufully then return pass:true otherwise pass:false. * The amount also needs to be passed. * * * @returns */ validate_price_callback: function(){ let textObj = document.getElementById("dollar-amount"); let amount = app.utils.moneyFormat(textObj); return {pass:true,value:amount}; }, /** * Called right before submit. Validate any input then return object * with any data that needs to be passed through with the required * property pass = true|false. * @returns */ validation_callback: function(){ var nameValue = document.getElementById('card-name').value; var emailValue = document.getElementById('card-email').value; var charge = document.getElementById(amountId).innerHTML; if(nameValue=="" || emailValue==""){ alert("Please provide your name and email!"); return {pass: false}; } return { pass: true, name: nameValue, email: emailValue, charge: charge, amount: charge }; }, /** * Called when the transaction has been made successfully. * @param {*} orderData */ success_callback: function(paypalObj){ // nnnnn // AR2VfeqErRvgVHp6B9ZPRAtfLzEA4tTz__C1EU0F60lsq9GgCLYPAomMgxscP3xEA9qiptKgnEgbJiBQ // EDJNEZ7HofqGyGkBaSbuQvdbhWfGrkTp6sqXfA1T5Ry-OKrcnq-cm__vCcGy8Wx2LYmrPNyK5PBTBQB2 app.config.configurations.donations[0].json.reference_num = app.config.configurations.donations[0].json.reference_abbr + app.utils.numberId(6); app.config.configurations.donations[0].json.name = paypalObj.values.name; app.config.configurations.donations[0].json.email = paypalObj.values.email; app.config.configurations.donations[0].json.amount = paypalObj.values.amount; app.config.configurations.donations[0].json.orderData = paypalObj.orderData; app.config.configurations.donations[0].json.email_response.email = paypalObj.values.email; app.config.configurations.donations[0].json. variables.push({name: "email", value: paypalObj.values.email }); app.config.configurations.donations[0].json. variables.push({name: "fullname", value: paypalObj.values.name }); app.config.configurations.donations[0].json. variables.push({name: "amount", value: paypalObj.values.amount }); app.config.configurations.donations[0].json. variables.push({name: "reference_num", value: app.config.configurations.donations[0].json.reference_num }); let mydata = { "donation_apply_success": true, "category": app.config.configurations.donations[0].json.category, "reference_abbr": app.config.configurations.donations[0].json.reference_abbr, "reference_num": app.config.configurations.donations[0].json.reference_num, "reference_acct": app.config.configurations.donations[0].json.email, "json": JSON.stringify(app.config.configurations.donations[0].json) }; console.log(mydata); console.log(paypalObj); $.post(REQUEST_URL,mydata,function(resp){ console.log(resp); }); }, error_callback: function(err){ console.log(err); }, success_content: function(paypalObj){ console.log(paypalObj); return `

Thank you for your donation!

You will receive an email receipt to the email address you provided ${paypalObj.values.email} Continue to follow us and keep up to date with current events & news and how you can be a Cradle2career sponsor.
`}, }); } function __initialize_paypal(paypalContainerId, self){ self.afspayments.service.paypal().setupCheckout({ container_id: paypalContainerId, options: { appendNow: false, paypal_error_message: "Sorry, your transaction could not be processed, please try again.", showPaypalButton: true, showPaypalForm: true, billingAddressEnabled: true, billingAddressNameEnabled: true, onSubmit: { showButton: false, id: "sponsorship_submit_button" } }, validation_callback: function(){ return {pass: true}; }, validate_price_callback: function(){ console.log(self.sponsorship.json.form.selected_level); return {pass:true,value: self.sponsorship.json.form.selected_level.price}; }, success_callback: function(orderData){ console.log(orderData); self.sponsorship.json.order_data = orderData.processor_data; let acct_password = ""; let acct_name = ""; console.log(self.sponsorship.json.variables); for(let i=0; i < self.sponsorship.json.variables.length; i++){ if(self.sponsorship.json.variables[i]['name'] == "response_password"){ acct_password = self.sponsorship.json.variables[i]['value']; } // if(self.sponsorship.json.variables[i]['name'] == "response_email"){ // acct_name = self.sponsorship.json.variables[i]['value']; // } } acct_name = self.sponsorship.json.reference_acct; removeFormDataObject(self); addSystemNeededVariables(self); variableReplacement(self); let mydata = { new_sponsorship: true, category: self.sponsorship.json.category, reference_num: self.sponsorship.json.reference_num, reference_abbr: self.sponsorship.json.reference_abbr, reference_acct: self.sponsorship.json.reference_acct, acct_name: acct_name, password_hash: acct_password, acct_email: self.sponsorship.json.reference_acct, quick_view_token: self.sponsorship.json.quick_view_token, domain: JSON.stringify(self.domain), json: JSON.stringify(self.sponsorship.json) }; console.log(mydata); console.log(self.sponsorship); $.post('../../core/php/request.php',mydata,function(e){ console.log(e); }); }, error_callback: function(err){ console.log(err); }, success_content: function(orderData){ return self.variablesReplace(self.sponsorship.json.success_message,"hash"); } }); }// end gl_process_payment_sponsorship }); });// end post client html template function application_loader_screen_html(){ return `
Preparing dashboard
`; } })();// END function