MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
update LatAm feeMinimums
simplify locale code: just define donationForm.locale on load and use that as default for formatAmount
 
(17 intermediate revisions by 2 users not shown)
Line 7:
 
donationForm.loadedTime = Date.now();
donationForm.extraData = {};
'vw' : window.innerWidth,
'vh' : window.innerHeight
};
 
if ( navigator.brave !== undefined ) { // T283367
donationForm.extraData.brave = '1';
}
 
// Don't offer recurring at all in these countries
donationForm.noRecurringCountries = [ 'AR', 'CL',]; 'CO',// 'MX',is 'PE',this 'UY',still 'BR' ];needed?
 
donationForm.maxUSDnoRecurringPaypalCountries = 25000[ 'CL', 'CO', 'PE', 'UY', 'BR' ];
 
donationForm.minimumscurrencyRates = {
// From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php
// Updated 2024-0107-1931
'ADF' : 6.0804,
'ADP' : 154153,
'AED' : 3.67,
'AFA' : 6870,
'AFN' : 6870,
'ALL' : 9490,
'AMD' : 388368,
'ANG' : 1.79,
'AOA' : 828844,
'AON' : 828844,
'ARS' : 366887,
'ATS' : 13,
'AUD' : 1.525,
'AWG' : 1.79,
'AZM' : 8500,
'AZN' : 1.7,
'BAM' : 1.818,
'BBD' : 2,
'BDT' : 109116,
'BEF' : 37,
'BGL' : 1.818,
'BGN' : 1.818,
'BHD' : 0.3745280208054737355757356689,
'BIF' : 28262842,
'BMD' : 1,
'BND' : 1.3435,
'BOB' : 6.7371,
'BRL' : 45.951,
'BSD' : 1,
'BTN' : 83,
'BWP' : 1413,
'BYR' : 3290032642,
'BZD' : 1.9798,
'CAD' : 1.36,
'CDF' : 26112786,
'CHF' : 0.876203623890759094629289448,
'CLP' : 880890,
'CNY' : 7.1723,
'COP' : 39703803,
'CRC' : 520498,
'CUC' : 1,
'CUP' : 25,
'CVE' : 102101,
'CYP' : 0.5426483597987453848627984321,
'CZK' : 23,
'DEM' : 1.818,
'DJF' : 178,
'DKK' : 6.9186,
'DOP' : 5658,
'DZD' : 134133,
'ECS' : 24094,
'EEK' : 1514,
'EGP' : 3147,
'ESP' : 154153,
'ETB' : 5657,
'EUR' : 0.9271697697125192005843390143,
'FIM' : 5.5147,
'FJD' : 2.2223,
'FKP' : 0.7958197171863878703952551207,
'FRF' : 6.0804,
'GBP' : 0.7958197171863878703952551207,
'GEL' : 2.6471,
'GHC' : 120114143125,
'GHS' : 1214,
'GIP' : 0.7958197171863878703952551207,
'GMD' : 6768,
'GNF' : 85228493,
'GRD' : 316314,
'GTQ' : 7.6457,
'GYD' : 200,
'HKD' : 7.818,
'HNL' : 24,
'HRK' : 6.9993,
'HTG' : 131132,
'HUF' : 355,
'IDR' : 1559315986,
'IEP' : 0.7302055325139172460490043714,
'ILS' : 3.7169,
'INR' : 1083,
'IQD' : 12921290,
'IRR' : 4200042009,
'ISK' : 140138,
'ITL' : 17951781,
'JMD' : 154,
'JOD' : 0.70900000000001,
'JPY' : 146156,
'KES' : 153130,
'KGS' : 8988,
'KHR' : 40513993,
'KMF' : 456453,
'KPW' : 135,
'KRW' : 13131358,
'KWD' : 0.3076216472886530629670764681,
'KYD' : 0.83333299999999,
'KZT' : 456442,
'LAK' : 2057721103,
'LBP' : 1500089393,
'LKR' : 325298,
'LRD' : 187193,
'LSL' : 1918,
'LTL' : 3.218,
'LUF' : 37,
'LVL' : 0.6516186228330464662074757963,
'LYD' : 4.8,
'MAD' : 109.79,
'MDL' : 1817,
'MGA' : 45494379,
'MGF' : 9150,
'MKD' : 5756,
'MMK' : 20802075,
'MNT' : 2620,
'MOP' : 8.0403,
'MRO' : 392391,
'MTL' : 0.3980339821375939498108567387,
'MUR' : 4345,
'MVR' : 15,
'MWK' : 16741720,
'MXN' : 17,
'MYR' : 4.68,
'MZM' : 63200,
'MZN' : 63,
'NAD' : 1918,
'NGN' : 7911505,
'NIO' : 36,
'NLG' : 2.0403,
'NOK' : 11,
'NPR' : 132131,
'NZD' : 1.63,
'OMR' : 0.3838121251183638377594841305,
'PAB' : 1,
'PEN' : 3.7467,
'PGK' : 3.6476,
'PHP' : 5658,
'PKR' : 283277,
'PLN' : 43.0291,
'PTE' : 186184,
'PYG' : 72447355,
'QAR' : 3.6456,
'ROL' : 4606345713,
'RON' : 4.6157,
'RSD' : 108,
'RUB' : 9091,
'RWF' : 12371277,
'SAR' : 3.75,
'SBD' : 8.3537,
'SCR' : 13,
'SDD' : 59800,
'SDG' : 598,
'SDP' : 2261,
'SEK' : 1011,
'SGD' : 1.3435,
'SHP' : 0.7958197171863878703952551207,
'SIT' : 222220,
'SKK' : 28,
'SLL' : 19750,
'SOS' : 562549,
'SRD' : 3733,
'SRG' : 3735633320,
'STD' : 2255222477,
'SVC' : 8.75,
'SYP' : 513,
'SZL' : 1918,
'THB' : 36,
'TJS' : 11,
Line 192 ⟶ 185:
'TND' : 3.11,
'TOP' : 2.32,
'TRL' : 2900900732168418,
'TRY' : 2932,
'TTD' : 6.6564,
'TWD' : 3132,
'TZS' : 24982587,
'UAH' : 3739,
'UGX' : 37843760,
'USD' : 1,
'UYU' : 3938,
'UZS' : 1230212662,
'VEB' : 35538253263651907631,
'VEF' : 35538253651908,
'VND' : 2425925451,
'VUV' : 112,
'WST' : 2.6867,
'XAF' : 608604,
'XAG' : 0.043725386677957031347411860134,
'XAU' : 0.00050403891928600041128929241299,
'XCD' : 2.7,
'XEU' : 0.9271697697125192005843390143,
'XOF' : 608604,
'XPD' : 0.00102593750718600098009826645798,
'XPF' : 111110,
'XPT' : 0.00108407857295400093444018680404,
'YER' : 250249,
'YUN' : 108,
'ZAR' : 1918,
'ZMK' : 5176,
'ZWD' : 373
Line 225 ⟶ 218:
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency = donationForm.currency,;
minAmount = donationForm.minimums[ currency ],
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
// Round up
minAmount = Math.ceil( minAmount * 100 ) / 100;
 
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( minAmount, localedonationForm.minLocal ) + '\xa0' + currency );
});
 
Line 245 ⟶ 233:
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( donationForm.maxUSD * minAmount, localemaxLocal ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
.replace( '$4', donationForm.formatAmount( donationForm.maxUSD, locale ) );
});
};
Line 274 ⟶ 262:
// If changing, please update https://docs.google.com/spreadsheets/d/1e02TsZ_bKDAS1BMVBCdyo9D7RGln_wCGnkg7IF5kU5s/edit
var radioAmountsData = {
"USD" : { // also used for CAD, AUD, NZD, GBP, EUR"
"default" : [
[ 0, [ 2.75, 5, 10, 20, 25, 35, 50 ] ],
Line 292 ⟶ 280:
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"2incvarFY2425_E1_T11" : [
[ 0, [ 13.75, 5, 10, 1520, 2025, 3035, 50 ] ],
[ 35, [ 35, 510, 1015, 20, 35, 50, 75100 ] ],
[ 610, [ 610, 1015, 20, 3525, 5035, 7550, 100 ] ],
[ 1015, [ 1015, 1520, 25, 5035, 7550, 100 75, 125100 ] ],
[ 1320, [ 1320, 2025, 35, 50, 75, 100, 125150 ] ],
[ 1625, [ 1625, 2530, 5040, 7550, 100 75, 150100, 200150 ] ],
[ 2035, [ 2035, 3550, 5075, 75100, 125200, 150300, 200500 ] ],
[ 2350, [ 2350, 3575, 50100, 75200, 125300, 175500, 250750 ] ],
[ 2675, [ 2675, 35100, 50150, 75250, 125500, 175750, 2501000 ] ],
[ 30100, [ 30100, 40150, 50250, 75500, 125750, 1751000, 2502500 ] ],
[ 35150, [ 35150, 45200, 50300, 100500, 125750, 1751000, 2502000 ] ],
[ 40200, [ 40200, 50300, 75500, 100750, 1501000, 2502500, 3005000 ] ],
[ 45500, [ 45500, 50750, 751000, 1002500, 1505000, 2507500, 50010000 ] ],
[ 501000, [ 501000, 602000, 1003000, 1254000, 1755000, 2507500, 50010000 ] ],
[ 603000, [ 603000, 754000, 1005000, 1256000, 1757500, 25010000, 50012000 ] ],
[ 70, [ 70, 85, 100, 125, 175, 250, 500 ] ],
[ 80, [ 80, 100, 125, 150, 200, 300, 500 ] ],
[ 90, [ 90, 100, 125, 150, 200, 300, 500 ] ],
[ 100, [ 100, 125, 175, 250, 350, 500, 750 ] ],
[ 125, [ 125, 150, 200, 300, 500, 750, 1000 ] ],
[ 150, [ 150, 175, 250, 400, 500, 750, 1000 ] ],
[ 175, [ 175, 200, 300, 400, 500, 750, 1000 ] ],
[ 200, [ 200, 250, 300, 400, 500, 750, 1000 ] ]
],
"3incvarsvFY2425_E1_T14_US" : [
[ 0, [ 12.75, 5, 7.50 10, 1020, 1525, 2035, 3050 ] ],
[ 35, [ 32.75, 5, 10, 1520, 2025, 2535, 4050 ] ],
[ 610, [ 62.75, 10, 15, 20, 3025, 4035, 50 ] ],
[ 1015, [ 102.75, 1510, 20, 2530, 3050, 4075, 50100 ] ],
[ 1320, [ 133.75, 2010, 25, 35, 4550, 5575, 75100 ] ],
[ 1625, [ 164.50, 2010, 25, 35, 4550, 5575, 75100 ] ],
[ 2035, [ 206.75, 2515, 3530, 4550, 5575, 75100, 100150 ] ],
[ 2375, [ 2315.75, 3050, 3775, 45100, 55200, 75300, 100500 ] ],
[ 26100, [ 2624.75, 3050, 3775, 45100, 55200, 75300, 100500 ] ],
[ 30150, [ 3044.75, 35100, 40150, 45250, 55500, 75750, 1001000 ] ],
[ 35200, [ 3550, 40100, 45150, 50250, 65500, 75750, 1001000 ] ],
[ 40500, [ 40150, 45250, 50300, 65500, 75750, 1001000, 1252000 ] ],
[ 451000, [ 45250, 50500, 55750, 651000, 752500, 1005000, 12510000 ] ],
[ 503000, [ 50500, 601000, 752000, 1003500, 1255000, 1507500, 20010000 ] ],
[ 60, [ 60, 70, 80, 100, 125, 150, 200 ] ],
[ 70, [ 70, 80, 100, 125, 150, 200, 250 ] ],
[ 80, [ 80, 90, 100, 125, 150, 200, 250 ] ],
[ 90, [ 90, 100, 125, 150, 200, 250, 300 ] ],
[ 100, [ 100, 110, 150, 200, 250, 300, 350 ] ],
[ 125, [ 125, 150, 200, 250, 300, 400, 500 ] ],
[ 150, [ 150, 175, 200, 250, 300, 400, 500 ] ],
[ 175, [ 175, 200, 250, 300, 400, 500, 750 ] ],
[ 200, [ 200, 250, 300, 350, 400, 500, 750 ] ]
],
"4HA7FY2425_E1_T21_US" : [
[ 0, [ 2.75, 5, 10, 20, 25, 35, 100 50 ] ],
[ 5, [ 2.75, 5, 10, 1520, 2025, 35, 50, 200 ] ],
[ 10, [ 10 5, 1510, 2015, 2520, 35, 50, 250100 ] ],
[ 15, [ 1510, 2015, 2520, 3525, 5035, 7550, 300100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 100, 500 ] ],
[ 25, [ 2520, 3025, 4035, 50, 75, 100, 500150 ] ],
[ 35, [ 3525, 5030, 7540, 100 50, 200 75, 300100, 1000 150 ] ],
[ 7550, [ 7535, 100 50, 150 75, 250100, 500200, 750300, 2000 500 ] ],
[ 100 75, [ 100 50, 150 75, 250100, 500200, 750300, 1000 500, 5000 750 ] ],
[ 150100, [ 150 75, 200100, 300150, 500250, 750500, 1000 750, 75001000 ] ],
[ 200150, [ 200100, 300150, 250, 500, 750, 1000, 2500, 10000 ] ],
[ 500200, [ 500150, 750200, 1000 300, 2500 500, 5000 750, 75001000, 12000 2000 ] ],
[ 1000 500, [ 1000 200, 2000 300, 3000 500, 4000 750, 50001000, 75002500, 12000 5000 ] ],
[ 1000, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
"5LA1" : [
[ 0, [ 1, 5, 10, 15, 20, 30, 50 ] ],
[ 3, [ 3, 5, 10, 20, 35, 50, 75 ] ],
[ 6, [ 5, 10, 20, 35, 50, 75, 100 ] ],
[ 10, [ 10, 15, 25, 50, 75, 100, 125 ] ],
[ 13, [ 10, 20, 35, 50, 75, 100, 125 ] ],
[ 16, [ 15, 25, 50, 75, 100, 150, 200 ] ],
[ 20, [ 20, 35, 50, 75, 125, 150, 200 ] ],
[ 23, [ 20, 35, 50, 75, 125, 175, 250 ] ],
[ 26, [ 25, 35, 50, 75, 125, 175, 250 ] ],
[ 30, [ 30, 40, 50, 75, 125, 175, 250 ] ],
[ 35, [ 35, 45, 50, 100, 125, 175, 300 ] ],
[ 40, [ 40, 50, 75, 100, 150, 200, 300 ] ],
[ 45, [ 45, 50, 75, 100, 150, 250, 500 ] ],
[ 50, [ 50, 75, 100, 125, 175, 250, 500 ] ],
[ 60, [ 60, 75, 100, 125, 175, 250, 500 ] ],
[ 70, [ 70, 85, 100, 125, 175, 250, 500 ] ],
[ 80, [ 80, 100, 125, 150, 200, 300, 500 ] ],
[ 90, [ 90, 100, 125, 150, 200, 300, 500 ] ],
[ 100, [ 100, 125, 175, 250, 350, 500, 750 ] ],
[ 125, [ 125, 150, 200, 300, 500, 750, 1000 ] ],
[ 150, [ 150, 200, 300, 400, 500, 750, 1000 ] ],
[ 175, [ 175, 200, 300, 400, 500, 750, 1000 ] ],
[ 200, [ 200, 225, 300, 400, 500, 750, 1000 ] ]
],
"2018control" : [
[ 0, [ 5, 10, 20, 25, 35, 50, 100 ] ],
[ 5, [ 10, 15, 20, 35, 50, 100, 150 ] ],
[ 10, [ 15, 20, 25, 35, 50, 100, 150 ] ],
[ 15, [ 20, 25, 35, 50, 75, 100, 250 ] ],
[ 20, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 25, [ 30, 40, 50, 75, 100, 150, 250 ] ],
[ 35, [ 25, 50, 75, 100, 200, 250, 300 ] ],
[ 75, [ 25, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 25, 50, 100, 150, 250, 500, 1000 ] ],
[ 150, [ 50, 100, 150, 200, 350, 500, 1000 ] ],
[ 200, [ 100, 150, 200, 300, 400, 500, 1000 ] ],
[ 500, [ 100, 250, 500, 750, 1000, 1500, 2000 ] ],
[ 1000, [ 500, 1000, 2000, 2500, 3000, 4000, 5000 ] ]
],
"LTLA" : [
[ 0, [ 3, 10, 15, 20, 35, 50, 100 ] ],
[ 5, [ 5, 10, 20, 35, 50, 100, 150 ] ],
[ 10, [ 10, 20, 35, 50, 75, 100, 150 ] ],
[ 15, [ 15, 25, 35, 50, 75, 100, 250 ] ],
[ 20, [ 20, 30, 50, 75, 100, 150, 250 ] ],
[ 25, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 35, [ 25, 50, 75, 100, 200, 250, 300 ] ],
[ 75, [ 25, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 25, 50, 100, 150, 250, 500, 1000 ] ],
[ 150, [ 50, 100, 150, 200, 350, 500, 1000 ] ],
[ 200, [ 100, 150, 200, 300, 400, 500, 1000 ] ],
[ 500, [ 100, 250, 500, 750, 1000, 1500, 2000 ] ],
[ 1000, [ 500, 1000, 2000, 2500, 3000, 4000, 5000 ] ]
],
"midtier2018" : [
Line 427 ⟶ 345:
[ 500, [ 750, 1000, 1500, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
"EUR" : {
"default" : [ // also used for GBP
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T14_GB" : [
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 2, 10, 15, 20, 25, 35, 50 ] ],
[ 15, [ 2, 10, 20, 30, 50, 75, 100 ] ],
[ 20, [ 3, 10, 25, 35, 50, 75, 100 ] ],
[ 25, [ 4, 10, 25, 35, 50, 75, 100 ] ],
[ 35, [ 6, 15, 30, 50, 75, 100, 150 ] ],
[ 75, [ 15, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 25, 50, 75, 100, 200, 300, 500 ] ],
[ 150, [ 45, 100, 150, 250, 500, 750, 1000 ] ],
[ 200, [ 50, 100, 150, 250, 500, 750, 1000 ] ],
[ 500, [ 150, 250, 300, 500, 750, 1000, 2000 ] ],
[ 1000, [ 250, 500, 750, 1000, 2500, 5000, 10000 ] ],
[ 3000, [ 500, 1000, 2000, 3500, 5000, 7500, 10000 ] ]
],
"FY2425_E1_T21_GB" : [
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 15, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 25, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 35, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 50, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 75, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 150, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 200, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 500, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 1000, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
Line 449 ⟶ 419:
radioAmountsData.AUD = radioAmountsData.USD;
radioAmountsData.CAD = radioAmountsData.USD;
radioAmountsData.GBP = radioAmountsData.USD;
radioAmountsData.NZD = radioAmountsData.USD;
 
radioAmountsData.EUR = radioAmountsData.USD;
radioAmountsData.GBP = radioAmountsData.EUR;
 
var appealAmountsData = {
"USD" : [ // also used for CAD, AUD, NZD, GBP, EUR
Line 680 ⟶ 650:
 
var params = {};
 
params.currency = donationForm.currency;
params.country = donationForm.country;
Line 694 ⟶ 664:
params.payment_method = paymentMethod;
}
 
if ( params.payment_method === 'cc' && params.country === 'ZA' ) {
params.gateway = 'astropay';
Line 776 ⟶ 746:
uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:AdyenCheckoutGateway');
}
 
// Skip form chooser for Venmo
if ( params.payment_method === 'venmo' ) {
Line 785 ⟶ 755:
 
// Tracking data
params.utm_mediumwmf_medium = mw.util.getParamValue( 'wmf_medium' ) || mw.util.getParamValue( 'utm_medium' );
params.utm_campaignwmf_campaign = mw.util.getParamValue( 'wmf_campaign' ) || mw.util.getParamValue( 'utm_campaign' );
params.utm_sourcewmf_source = donationForm.buildUtmSourcebuildTrackingSource( params );
params.utm_keywmf_key = donationForm.buildUtmKeybuildTrackingKey( donationForm.extraData );
if ( document.referrer ) { // TODO: do we need this?
// Strip protocol to stop firewall complaining
Line 805 ⟶ 775:
 
/**
* Build a utm_sourcewmf_source value, including the landing page info.
*
* Own function so it can be overriden for weird tests
*
* @param {Object} params
* @return {string} utm_sourcewmf_source
*/
donationForm.buildUtmSourcebuildTrackingSource = function( params ) {
 
var utm_sourcewmf_source = mw.util.getParamValue( 'utm_sourcewmf_source' ) +|| 'mw.util.getParamValue( 'utm_source' );
wmf_source += '.';
 
var fullDottedPaymentMethod = params.payment_method;
Line 834 ⟶ 805:
 
/* The landing page info, separated by ~. This mostly exists for legacy reasons */
utm_sourcewmf_source += getParam( 'template' , 'Lp-layout' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'appeal-template' , 'Appeal-template-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'appeal' , 'Appeal-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'form-template' , 'Form-template-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'form-countryspecific', 'Form-countryspecific-', 'control' );
 
utm_sourcewmf_source += '.' + fullDottedPaymentMethod;
 
return utm_sourcewmf_source;
 
};
 
/**
* Build a string for utm_keywmf_key from extra tracking data
*
* @param {Object} data
* @return {string} utm_keywmf_key
*/
donationForm.buildUtmKeybuildTrackingKey = function(data) {
var existingUtmKeyexistingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ),
dataArray = [];
 
if ( existingUtmKeyexistingKey ) {
dataArray.push( existingUtmKeyexistingKey );
}
for (var key in data) {
Line 951 ⟶ 922:
 
var amount = donationForm.getAmount();
var minAmount = donationForm.minimums[ donationForm.currency ] || 1;
 
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmountdonationForm.minLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').hide();
$('.lp-error-smallamount').show();
return false;
} else if ( amount > donationForm.maxUSD * minAmountmaxLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').show();
Line 981 ⟶ 951:
var selectedAmount = donationForm.getAmount(),
feeAmount = donationForm.calculateFee( selectedAmount ),
feeText;
minAmount = donationForm.minimums[ donationForm.currency ] || 1,
maxAmount = donationForm.maxUSD * minAmount,
feeText, locale;
 
localefeeText = donationForm.getLocaleformatAmount( mw.config.get('wgPageContentLanguage'), donationForm.countryfeeAmount );
feeText = donationForm.formatAmount( feeAmount, locale );
 
$('.ptf label span').text( feeText );
if ( selectedAmount + feeAmount <= maxAmountdonationForm.maxLocal ) {
$('.ptf').slideDown();
}
Line 1,123 ⟶ 1,090:
 
/**
* Format an amount for a given locale (default to donationForm.locale)
*
* 2 decimal places if it has a fractional part, 0 if not
* Note this doesn't include any currency symbol
*
* @param {number} amount
* @param {string} [locale=donationForm.locale] To determine correct separators
* @return {string}
*/
donationForm.formatAmount = function( amount, locale = donationForm.locale ) {
var formatterOptions, output;
if ( amount % 1 !== 0 ) { // Not a whole number
Line 1,336 ⟶ 1,303:
}
donationForm.country = mw.util.getParamValue('country').toUpperCase();
donationForm.locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
 
// Minimum amount is usually about 1 USD
donationForm.minLocal = donationForm.currencyRates[ donationForm.currency ];
donationForm.minLocal = Math.ceil( donationForm.minLocal * 100 ) / 100; // Round it up
donationForm.maxUSD = 25000;
donationForm.maxLocal = Math.floor( donationForm.currencyRates[ donationForm.currency ] * donationForm.maxUSD );
 
// Overrides for India
if ( donationForm.currency === 'INR' ) {
donationForm.minLocal = 10;
// Until https://phabricator.wikimedia.org/T370583 fixed?
donationForm.maxUSD = 3000;
donationForm.maxLocal = 250000;
}
 
// Block typing symbols in Other field
Line 1,367 ⟶ 1,349:
$('#frequency_onetime').prop('checked', true);
$('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide();
}
 
if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) {
$( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' );
}
 
Line 1,372 ⟶ 1,358:
 
// Only show Amazon for links from Ways to give
// TODO: remove utm_source when Ways to give has been updated
if (
if (
mw.util.getParamValue( 'utm_source' ) === 'Waystogive' ||
mw.util.getParamValue( 'utm_sourcewmf_source' ) === 'Ways_to_GiveWaystogive' ||
mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give'
) {
$('.paymentmethod-amazon').show();
}
 
Line 1,385 ⟶ 1,372:
}
}
 
// Venmo browser check
if ( $('.paymentmethod-venmo').length > 0 ) {
Line 1,408 ⟶ 1,395:
 
// Allow preselecting monthly
if (
mw.util.getParamValue('monthly')
&& mw.util.getParamValue('monthly') !== '0'
&& donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 ) {
&& donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1
) {
$('#frequency_monthly').click();
}
Line 1,421 ⟶ 1,411:
}
finally {
$('.frb-monthly-pitch, .frb-monthly-pitch-thanks').appendTo('.frequency-options');
$('.ptf').appendTo('.amount-options');
$('.optin-options').insertAfter('.amount-options');