PageSourceSearch

https://www.swissaid.ch/wp-content/cache/min/1/wp-content/themes/swissaid-theme/js/donation.js?ver=1790170389

js swissaid.ch collected 2026-09-24 21:39:39 UTC 6,087 bytes, 23 lines download raw bytes

1function donationPage(){if(!document.body.classList.contains('page-template-template-donation')){return}
2const config=window.swRaiseNowConfig||{};const root=document.querySelector("[data-raise-now-root]");const widget=document.getElementById("sa-raise-now-widget");if(!root||!widget){return}
3const amountQueries=["amount","custom_amount"];function loadScript(id,src){return new Promise((resolve,reject)=>{const existing=document.getElementById(id);if(existing){if(window.rnw){resolve();return}
4existing.addEventListener("load",resolve,{once:!0});existing.addEventListener("error",reject,{once:!0});return}
5const script=document.createElement("script");script.id=id;script.src=src;script.async=!0;script.onload=resolve;script.onerror=reject;document.head.appendChild(script)})}
6function parseParameterValue(value){if(value===undefined||value===null||value===""){return!1}
7return!isNaN(+value)?+value:!1}
8function defineDefaultAmount(query){return(parseParameterValue(query.get("amount"))||parseParameterValue(query.get("custom_amount"))||"")}
9function formPrefill(query,defaultFrequency){const data={};query.forEach((value,key)=>{if(amountQueries.includes(key)){data[key]=parseParameterValue(value)}else{data[key]=value}
10if(key==="frequency"||key==="rnw-frequency"){data.payment_type="recurring";data.recurring_interval=value}});data.payment_type=data.payment_type||"onetime";data.recurring_interval=data.recurring_interval||defaultFrequency||"monthly";return data}
11function getPurposesData(options,locale){const purposes=Array.isArray(options.purposes)?options.purposes:[];return{paymentWidgetBlocks:["payment_purposes","payment_amounts_and_intervals","payment_payment_methods","payment_profile",{if:"showPaymentAddress() == true",then:["payment_address"],},],purposes:purposes.map((item,index)=>`p${index + 1}`),translations:{[locale]:{purposes:purposes.reduce((previous,item,index)=>{previous[`p${index + 1}`]=item.text||"";return previous},{}),},},purposeDetails:purposes.reduce((previous,item,index)=>{const campaignObject={stored_campaign_id:item.campaign_id||"",};if(item.campaign_subid){campaignObject.stored_campaign_subid=item.campaign_subid}
12previous[`p${index + 1}`]=campaignObject;return previous},{}),}}
13function setCampaignId(options){return function(event){const api=event.data.api;const formData=api.paymentForm.data;let emailSubject="";if(!options.has_purpose){formData.stored_campaign_id=options.campaign_id||"10064";formData.stored_campaign_subid=options.campaign_subid||""}
14if(options.has_purpose&&formData.purpose&&Array.isArray(options.purposes)){const purposeIndex=String(formData.purpose).replace("p","");const purpose=options.purposes[Number(purposeIndex)-1];if(purpose&&purpose.email_subject){emailSubject=purpose.email_subject}}
15formData.stored_customer_email_permission=!0;formData.stored_email_subject_text=emailSubject||options.email_subject||""}}
16loadScript("raise-now-js","https://tamaro.raisenow.com/swissaid-ch/latest/widget.js",).then(()=>{if(!window.rnw||!window.rnw.tamaro){return}
17const query=new URLSearchParams(window.location.search);const locale=config.locale||"de";const options=config.options||{};const amountSettings=Array.isArray(config.amountSettings)?config.amountSettings:[];const isProduction=window.location.hostname.indexOf("swissaid.ch")!==-1;window.rnw.tamaro.events.beforePaymentValidateAndSend.subscribe(setCampaignId(options),);window.rnw.tamaro.events.beforePaymentSend.subscribe((event)=>{if(!config.redirectThankYouPage){return}
18const data=event.data.api.paymentForm.data||{};sessionStorage.setItem("donation-data",JSON.stringify({firstName:data.stored_customer_firstname||"",lastName:data.stored_customer_lastname||"",amount:data.amount||"",paymentType:data.payment_type||"",project:options.project_name||null,}),)});window.rnw.tamaro.events.paymentComplete.subscribe((event)=>{const api=event.data.api||{};const success=api.transactionInfo?.epayment_status==="success"||api.epmsPaymentInfo?.last_status==="succeeded"||api.epmsPaymentAgreementInfo?.payment_method==="ch_qr_reference";if(!success||!config.redirectThankYouPage){return}
19window.location.href=config.redirectThankYouPage+window.location.search});const defaultOptions={language:locale,debug:!isProduction,testMode:!isProduction,amounts:amountSettings.map((item)=>
19+item.amount).filter(Boolean),defaultAmount:defineDefaultAmount(query),minimumCustomAmount:options.minimum_amount||360,paymentFormPrefill:{...formPrefill(query,options.frequency||"monthly"),payment_type:"onetime",recurring_interval:options.frequency||"monthly",},slots:{recurring_intervals_start:[{component:"content",text_html:"frequency_custom_headline"},],recurring_intervals_end:[{component:"content",text_html:"frequency_custom_tooltipp"},],amounts_start:[{component:"content",text_html:"amount_custom_headline"},],profile_form_after_email:[{component:"content",text_html:"dsgvo_info"},],profile_form_start:[{component:"field",type:"checkbox",name:"stored_customer_company_check",label:"payment_form.donate_as_company",},],profile_form_3:[{component:"field",if:"paymentForm(stored_customer_company_check) == true",label:"payment_form.stored_customer_company",name:"stored_customer_company",type:"text",},],},};if(options.donation_type&&options.donation_type!=="both"){defaultOptions.paymentTypes=[options.donation_type]}
20if(query.get("rnw-frequency")){defaultOptions.paymentFormPrefill.recurring_interval=query.get("rnw-frequency");defaultOptions.paymentFormPrefill.payment_type="recurring"}
21const finalOptions={...defaultOptions,...options,allowedRecurringPaymentMethods:["card","paypal","twint","direct_debit",],paymentMethods:options.paymentMethods||["card","paypal","direct_debit","ch_qr_reference","twint",],};if(options.has_purpose){Object.assign(finalOptions,getPurposesData(options,locale))}
22if(config.redirectThankYouPage){finalOptions.epikConfig={successUrl:config.redirectThankYouPage,eppEnv:"prod",eppApiKey:"swi-o9rck8",eppMerchantId:"swi-hbs8p4",}}
23window.rnw.tamaro.runWidget("#sa-raise-now-widget",finalOptions)}).catch(()=>{console.warn("RaiseNow script could not be loaded.")})}

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.