MediaWiki:DonationFormSandbox.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 17:
 
// Don't offer recurring at all in these countries
donationForm.noRecurringCountries = [ 'AR', 'CL', 'CO', 'MX', 'PE', 'UY', 'BR', 'IN' ];
 
donationForm.maxUSD = 1200025000;
 
donationForm.maxUSD = 12000;
donationForm.minimums = {
/*/ From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php */
'ADF'// :Updated 5.45,2023-01-19
'ADPADF' : 1386.07,
'ADP' : 154,
'AED' : 3.67,
'AFA' : 7788,
'AFN' : 7788,
'ALL' : 102107,
'AMD' : 522375,
'ANG' : 1.79,
'AOA' : 622504,
'AON' : 622504,
'ARS' : 90183,
'ATS' : 1113,
'AUD' : 1.2945,
'AWG' : 1.79,
'AZM' : 8500,
'AZN' : 1.7,
'BAM' : 1.6381,
'BBD' : 2,
'BDT' : 83103,
'BEF' : 3437,
'BGL' : 1.6381,
'BGN' : 1.6381,
'BHD' : 0.3750371223512937464964546888,
'BIF' : 19272050,
'BMD' : 1,
'BND' : 1.3332,
'BOB' : 6.7473,
'BRL' : 5.6219,
'BSD' : 1,
'BTN' : 7381,
'BWP' : 1113,
'BYR' : 2606525223,
'BZD' : 1.97,
'CAD' : 1.2635,
'CDF' : 19752012,
'CHF' : 0.9237362764319191617710714192,
'CLP' : 729825,
'CNY' : 6.4778,
'COP' : 36604684,
'CRC' : 601556,
'CUC' : 1,
'CUP' : 25,
'CVE' : 92102,
'CYP' : 0.486622099303154127884625026,
'CZK' : 22,
'DEM' : 1.6381,
'DJF' : 178,
'DKK' : 6.1888,
'DOP' : 5756,
'DZD' : 133136,
'ECS' : 24094,
'EEK' : 1314,
'EGP' : 1630,
'ESP' : 138154,
'ETB' : 4053,
'EUR' : 0.8314432202747892482981688965,
'FIM' : 45.945,
'FJD' : 2.0217,
'FKP' : 0.7174344223174580951577817328,
'FRF' : 56.4507,
'GBP' : 0.7174344223174580951577817328,
'GEL' : 32.363,
'GHC' : 57159120475,
'GHS' : 5.7212,
'GIP' : 0.7174344223174580951577817328,
'GMD' : 5161,
'GNF' : 100418618,
'GRD' : 283315,
'GTQ' : 7.5367,
'GYD' : 201200,
'HKD' : 7.7683,
'HNL' : 24,
'HRK' : 6.397,
'HTG' : 76148,
'HUF' : 303365,
'IDR' : 1427915138,
'IEP' : 0.6548147483324872836266990886,
'ILS' : 3.34,
'INR' : 7310, // T309818
'IQD' : 14421444,
'IRR' : 4201041389,
'ISK' : 127143,
'ITL' : 16101791,
'JMD' : 149151,
'JOD' : 0.70900000000001,
'JPY' : 107128,
'KES' : 109123,
'KGS' : 8586,
'KHR' : 40194066,
'KMF' : 409455,
'KPW' : 135,
'KRW' : 11261235,
'KWD' : 0.3019115390725730458529862893,
'KYD' : 0.83333299999999,
'KZT' : 418462,
'LAK' : 917016719,
'LBP' : 1508,
'LKR' : 194363,
'LRD' : 173155,
'LSL' : 1517,
'LTL' : 23.8719,
'LUF' : 3437,
'LVL' : 0.5843416209819864997409462932,
'LYD' : 4.4275,
'MAD' : 8.8210,
'MDL' : 1719,
'MGA' : 37164315,
'MGF' : 9150,
'MKD' : 5157,
'MMK' : 13922081,
'MNT' : 2620,
'MOP' : 78.9906,
'MRO' : 357358,
'MTL' : 0.3569385744639639702944039072,
'MUR' : 3943,
'MVR' : 15,
'MWK' : 7701007,
'MXN' : 2119,
'MYR' : 4.0531,
'MZM' : 7388063200,
'MZN' : 7463,
'NAD' : 1517,
'NGN' : 380456,
'NIO' : 3536,
'NLG' : 12.8304,
'NOK' : 89.5292,
'NPR' : 115129,
'NZD' : 1.3856,
'OMR' : 0.3838395736509838361244843663,
'PAB' : 1,
'PEN' : 3.638,
'PGK' : 3.4344,
'PHP' : 4955,
'PKR' : 157229,
'PLN' : 34.7836,
'PTE' : 167185,
'PYG' : 65417291,
'QAR' : 3.6162,
'ROL' : 4051745542,
'RON' : 4.0555,
'RSD' : 97108,
'RUB' : 7469,
'RWF' : 9731064,
'SAR' : 3.75,
'SBD' : 78.8921,
'SCR' : 2013,
'SDD' : 3446757559,
'SDG' : 345576,
'SDP' : 2261,
'SEK' : 8.4510,
'SGD' : 1.3332,
'SHP' : 0.7174344223174580951577817328,
'SIT' : 199222,
'SKK' : 2528,
'SLL' : 1010519170,
'SOS' : 558560,
'SRD' : 1432,
'SRG' : 1401831535,
'STD' : 2030422638,
'SVC' : 8.75,
'SYP' : 513,
'SZL' : 1517,
'THB' : 3033,
'TJS' : 1110,
'TMM' : 1677016790,
'TMT' : 3.3536,
'TND' : 23.6909,
'TOP' : 2.2227,
'TRL' : 745695118787069,
'TRY' : 7.4619,
'TTD' : 6.6665,
'TWD' : 2830,
'TZS' : 23092328,
'UAH' : 2837,
'UGX' : 36413661,
'USD' : 1,
'UYU' : 4339,
'UZS' : 1042711275,
'VEB' : 1.86275657102E+141994566892,
'VEF' : 1862756571021994567,
'VND' : 2294023441,
'VUV' : 112,
'WST' : 2.4362,
'XAF' : 545607,
'XAG' : 0.038609238198237042455323695749,
'XAU' : 0.00058453703815200052193528164699,
'XCD' : 2.7,
'XEU' : 0.8314432202747892482981688965,
'XOF' : 545607,
'XPD' : 0.00042350786636400058093239109499,
'XPF' : 99110,
'XPT' : 0.0008536716746060300096625574498098,
'YER' : 250,
'YUN' : 97108,
'ZAR' : 1517,
'ZMK' : 5176,
'ZWD' : 373
Line 528 ⟶ 530:
};
 
if ( formats[currency] ) {
var format = formats[currency][language] || formats[currency]['default'] || formats[currency] || '\t';
} else }{
var format = '\t';
}
 
// Radio button amounts
Line 640 ⟶ 646:
'SK' : 'vmaj',
// Others
'CZ' : 'vmad',
'DK' : 'vma',
'HU' : 'vma',
'IL' : 'vmad', // Adyen
'JP' : 'vmjvmaj',
'MY' : 'vmaj',
'NO' : 'vma',
Line 650 ⟶ 657:
'SE' : 'vma',
'UA' : 'vma', // Adyen
'ZA' : 'vm',
'ZZ' : 'vmad' // For testing
};
if ( cardTypes[country] ) {
Line 684 ⟶ 692:
 
var params = {};
params.currency_codecurrency = donationForm.currency;
params.country = donationForm.country;
 
// Overrides for specific cc gateways
Line 689 ⟶ 700:
params.payment_method = 'cc';
params.gateway = 'adyen';
params.ffname = 'adyen';
} else if ( paymentMethod === 'cc-dlocal' ) {
params.payment_method = 'cc';
Line 695 ⟶ 705:
} else {
params.payment_method = paymentMethod;
}
if ( donationFormparams.payment_method === 'cc' && params.country === 'INZA' ) {
params.ffnamegateway = 'adyenastropay';
}
 
Line 708 ⟶ 722:
}
 
params.currency_code = donationForm.currency;
params.country = donationForm.country;
params.uselang = mw.config.get('wgPageContentLanguage'); // see T281285 for why not wgUserLanguage
 
Line 735 ⟶ 747:
var opt_inValue = $('input[name="opt_in"]:checked').val();
params.opt_in = opt_inValue; // donationForm.validate() already checked it's 1 or 0
}
 
// Default to variant = panExplain for India
// TODO: make this default payments side - https://phabricator.wikimedia.org/T259146
if ( donationForm.country === 'IN' ) {
params.variant = 'panExplain';
}
 
Line 746 ⟶ 752:
params.variant = mw.util.getParamValue( 'pym_variant' );
}
if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) {
// Post-payments monthly convert makes no sense if it's already recurring
// Avoid things like T312905
delete params.variant = 'panExplain';
}
 
if ( mw.util.getParamValue( 'pym_appeal' ) ) {
params.appeal = mw.util.getParamValue( 'pym_appeal' );
Line 770 ⟶ 782:
donationForm.finalStep = function( params ) {
 
var uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:GatewayFormChooserGatewayChooser');
 
// Skip form chooser for Apple Pay / Google Pay
if ( params.payment_method === 'apple' || params.payment_method === 'google' ) {
uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:AdyenCheckoutGateway');
}
 
donationForm.extraData.time = Math.round( (Date.now() - donationForm.loadedTime)/1000 );
Line 1,000 ⟶ 1,017:
'HUF' : 100,
'ILS' : 1.2,
'INR' : 254,
'JPY' : 35,
'MYR' : 1,
'NOK' : 3,
'PLN' : 1.35,
'CZK' : 7.5,
'RON' : 1.5,
'SEK' : 3,
Line 1,105 ⟶ 1,123:
*/
donationForm.shouldShowApplePay = function ( country ) {
// TODO: Add country logic when we get a list from payments
if ( location.search.match('forceApplePay') ) {
return true;
Line 1,127 ⟶ 1,144:
 
// These get used in quite a few places
try {
donationForm.currency = form.currency_code.value;
} catch (error) {
donationForm.country = mw.util.getParamValue('country');
donationForm.currency = 'USD';
}
donationForm.country = mw.util.getParamValue('country').toUpperCase();
 
// Block typing symbols in Other field