MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
update minimums to match payments
add donationForm.currencyRates; define donationForm.minLocal and maxLocal at load and allow overriding (currently only for India)
Line 14:
donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ];
 
donationForm.maxUSDcurrencyRates = 25000;{
 
donationForm.minimums = {
// From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php
// Updated 2024-07-31
Line 97 ⟶ 95:
'IEP' : 0.72460490043714,
'ILS' : 3.69,
'INR' : 1083,
'IQD' : 1290,
'IRR' : 42009,
Line 220 ⟶ 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( minAmountdonationForm.minLocal, locale ) + '\xa0' + currency );
});
 
Line 240 ⟶ 234:
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( donationForm.maxUSD * minAmountmaxLocal, locale ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
Line 929 ⟶ 923:
 
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 959 ⟶ 952:
var selectedAmount = donationForm.getAmount(),
feeAmount = donationForm.calculateFee( selectedAmount ),
minAmount = donationForm.minimums[ donationForm.currency ] || 1,
maxAmount = donationForm.maxUSD * minAmount,
feeText, locale;
 
Line 967 ⟶ 958:
 
$('.ptf label span').text( feeText );
if ( selectedAmount + feeAmount <= maxAmountdonationForm.maxLocal ) {
$('.ptf').slideDown();
}
Line 1,314 ⟶ 1,305:
}
donationForm.country = mw.util.getParamValue('country').toUpperCase();
 
// Minimum amount is usually about 1 USD
var minAmount donationForm.minLocal = donationForm.minimumscurrencyRates[ donationForm.currency ] || 1;
donationForm.minLocal = Math.ceil( donationForm.minLocal * 100 ) / 100; // Round it up
donationForm.minimumsmaxUSD = {25000;
minAmountdonationForm.maxLocal = Math.floor( donationForm.minimumscurrencyRates[ donationForm.currency ] ||* donationForm.maxUSD 1,);
 
// Overrides for India
minAmountif =( donationForm.minimums[ currency ],=== 'INR' ) {
donationForm.minLocal = 10;
// Until https://phabricator.wikimedia.org/T370583 fixed?
maxAmount = donationForm.maxUSD * minAmount, = 3000;
donationForm.maxLocal = 250000;
}
 
// Block typing symbols in Other field