Template:2012FR/Form-section/Processing/Default: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
fix, && doesn't work here
note why this is kept
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!-- Merged to MediaWiki:DonationForm.js. Kept this page for the history. -->
<html>
<script>
var donationForm = {};

donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {

var form = document.paypalcontribution; // we should really change this some day
if ( skipValidation || validateForm(form) ) {

if (typeof paymentSubMethod == 'undefined') {
paymentSubMethod = '';
}
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';

form.action = paymentsURL;

// set up inputs
form.currency_code.value = '</html>{{{currency|USD}}}<html>';

if (typeof paymentSubMethod == 'undefined') {
paymentSubMethod = '';
}

// WorldPay override for cc
if( paymentMethod === 'cc-wp' ) {
paymentMethod = 'cc';
form.payment_method.value = 'cc';
form.gateway.value = 'worldpay';
form.ffname.value = 'worldpay';
}

// Adyen override for cc
if( paymentMethod === 'cc-adyen' ) {
paymentMethod = 'cc';
form.payment_method.value = 'cc';
form.gateway.value = 'adyen';
form.ffname.value = 'adyen';
}

/* Temporary redirect variant for 3DS issues - https://phabricator.wikimedia.org/T219445 */
var country = form.country.value;
if ( paymentMethod === 'cc' ) {
if ( country === 'NO' || country === 'SE' || country === 'PL' ) {
form.variant.value = 'redirect';
}
}

var frequency = $("input[name='frequency']:checked").val();
if( frequency !== 'monthly' ){
frequency = 'onetime';
form.recurring.value = 'false';
} else {
form.recurring.value = 'true';
}

form.payment_method.value = paymentMethod;
form.payment_submethod.value = paymentSubMethod;

donationForm.addAnalytics();

var full_dotted_payment_method = paymentMethod;
if ( form.recurring.value == 'true' ) {
full_dotted_payment_method = 'r' + full_dotted_payment_method;
}
if ( paymentSubMethod ) {
full_dotted_payment_method = form.payment_method.value + '.' + paymentSubMethod;
}

form.utm_source.value += '.' + full_dotted_payment_method;

form.method = "GET";
form.submit();
}

return false; // don't submit if called by a button
};

donationForm.addAnalytics = function() {
// stuffs parameters into utm_source to make them available for analytics

var form = document.paypalcontribution;

form.utm_source.value = getQuerystring( 'utm_source' ) + '.';

if(getQuerystring( 'template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
}

if(getQuerystring( 'appeal-template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
}

if(getQuerystring( 'appeal' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
}

if(getQuerystring( 'form-template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
}

if(getQuerystring( 'form-countryspecific' ) == '') {
form.utm_source.value += 'control';
} else {
form.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
}

form.utm_campaign.value = getQuerystring( 'utm_campaign' );
};

donationForm.toggleMonthly = function(monthly) {
if (monthly) {
$('#form-wrapper').addClass('form-monthly');
} else {
$('#form-wrapper').removeClass('form-monthly');
}
};
</script>
</html>

Latest revision as of 13:04, 2 April 2019