MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
update LatAm feeMinimums
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 7:
 
donationForm.loadedTime = Date.now();
donationForm.extraData = {};
'vw' : window.innerWidth,
'vh' : window.innerHeight
};
 
// Don't offer recurring at all in these countries
if ( navigator.brave !== undefined ) { // T283367
donationForm.extraData.bravenoRecurringCountries = [ '1AR' ]; // is this still needed?
}
 
donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ];
// Don't offer recurring at all in these countries
donationForm.noRecurringCountries = [ 'AR', 'CL', 'CO', 'MX', 'PE', 'UY', 'BR' ];
 
donationForm.maxUSD = 25000;
Line 228 ⟶ 223:
minAmount = donationForm.minimums[ currency ],
locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
 
// Round up
minAmount = Math.ceil( minAmount * 100 ) / 100;
Line 274 ⟶ 269:
// 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 291 ⟶ 286:
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"2incvar" : [
[ 0, [ 1, 5, 10, 15, 20, 30, 50 ] ],
[ 3, [ 3, 5, 10, 20, 35, 50, 75 ] ],
[ 6, [ 6, 10, 20, 35, 50, 75, 100 ] ],
[ 10, [ 10, 15, 25, 50, 75, 100, 125 ] ],
[ 13, [ 13, 20, 35, 50, 75, 100, 125 ] ],
[ 16, [ 16, 25, 50, 75, 100, 150, 200 ] ],
[ 20, [ 20, 35, 50, 75, 125, 150, 200 ] ],
[ 23, [ 23, 35, 50, 75, 125, 175, 250 ] ],
[ 26, [ 26, 35, 50, 75, 125, 175, 250 ] ],
[ 30, [ 30, 40, 50, 75, 125, 175, 250 ] ],
[ 35, [ 35, 45, 50, 100, 125, 175, 250 ] ],
[ 40, [ 40, 50, 75, 100, 150, 250, 300 ] ],
[ 45, [ 45, 50, 75, 100, 150, 250, 500 ] ],
[ 50, [ 50, 60, 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, 175, 250, 400, 500, 750, 1000 ] ],
[ 175, [ 175, 200, 300, 400, 500, 750, 1000 ] ],
[ 200, [ 200, 250, 300, 400, 500, 750, 1000 ] ]
],
"3incvarsv" : [
[ 0, [ 1, 5, 7.50, 10, 15, 20, 30 ] ],
[ 3, [ 3, 5, 10, 15, 20, 25, 40 ] ],
[ 6, [ 6, 10, 15, 20, 30, 40, 50 ] ],
[ 10, [ 10, 15, 20, 25, 30, 40, 50 ] ],
[ 13, [ 13, 20, 25, 35, 45, 55, 75 ] ],
[ 16, [ 16, 20, 25, 35, 45, 55, 75 ] ],
[ 20, [ 20, 25, 35, 45, 55, 75, 100 ] ],
[ 23, [ 23, 30, 37, 45, 55, 75, 100 ] ],
[ 26, [ 26, 30, 37, 45, 55, 75, 100 ] ],
[ 30, [ 30, 35, 40, 45, 55, 75, 100 ] ],
[ 35, [ 35, 40, 45, 50, 65, 75, 100 ] ],
[ 40, [ 40, 45, 50, 65, 75, 100, 125 ] ],
[ 45, [ 45, 50, 55, 65, 75, 100, 125 ] ],
[ 50, [ 50, 60, 75, 100, 125, 150, 200 ] ],
[ 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 ] ]
],
"4HA7" : [
[ 0, [ 2.75, 5, 10, 20, 25, 35, 100 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 200 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 250 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 300 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 500 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 500 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 1000 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 2000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 5000 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 7500 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 10000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 12000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 12000 ] ]
],
"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 429 ⟶ 304:
]
},
"EUR" : [ // 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 ] ]
],
"JPY" : [
[ 0, [ 500, 1000, 2000, 2500, 4000, 5000, 10000 ] ],
Line 449 ⟶ 341:
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 ⟶ 572:
 
var params = {};
 
params.currency = donationForm.currency;
params.country = donationForm.country;
Line 694 ⟶ 586:
params.payment_method = paymentMethod;
}
 
if ( params.payment_method === 'cc' && params.country === 'ZA' ) {
params.gateway = 'astropay';
Line 776 ⟶ 668:
uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:AdyenCheckoutGateway');
}
 
// Skip form chooser for Venmo
if ( params.payment_method === 'venmo' ) {
Line 785 ⟶ 677:
 
// 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 ⟶ 697:
 
/**
* 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 ⟶ 727:
 
/* 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 1,124 ⟶ 1,017:
/**
* Format an amount for a given 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 To determine correct separators
Line 1,367 ⟶ 1,260:
$('#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,269:
 
// 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,283:
}
}
 
// Venmo browser check
if ( $('.paymentmethod-venmo').length > 0 ) {
Line 1,408 ⟶ 1,306:
 
// 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,322:
}
finally {
$('.frb-monthly-pitch, .frb-monthly-pitch-thanks').appendTo('.frequency-options');
$('.ptf').appendTo('.amount-options');
$('.optin-options').insertAfter('.amount-options');