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

Content deleted Content added
Created page with "<html> <script> function redirectPayment (legacyPaymentMethod) { // wrapper for redirectPayment2() // using old method parameters // until buttons can be updated ..."
 
note why this is kept
 
(44 intermediate revisions by 3 users not shown)
Line 1:
<!-- Merged to MediaWiki:DonationForm.js. Kept this page for the history. -->
<html>
<script>
function redirectPayment (legacyPaymentMethod) {
// wrapper for redirectPayment2()
// using old method parameters
// until buttons can be updated
 
switch (legacyPaymentMethod) {
case 'cc':
redirectPayment2('cc');
break;
 
case 'paypal':
case 'pp':
case 'ew-pp':
case 'ew-rpp':
case 'ew-pp-usd':
case 'ew-pp-eur':
redirectPayment2('paypal');
break;
 
case 'dd':
redirectPayment2('dd');
break;
 
case 'rtbt-id':
redirectPayment2('rtbt', 'rtbt_ideal');
break;
 
case 'ew-yd':
redirectPayment2('ew', 'ew_yandex');
break;
 
case 'rtbt-sf':
redirectPayment2('rtbt', 'rtbt_sofortuberweisung');
break;
 
case 'ew-amazon':
redirectPayment2('amazon');
break;
 
case 'obt-bp':
redirectPayment2('obt', 'bpay');
break;
 
case 'ew-wm':
redirectPayment2('ew', 'ew_webmoney');
break;
 
case 'cash-bl':
redirectPayment2('cash', 'boleto');
break;
 
case 'rtbt-en':
redirectPayment2('rtbt', 'rtbt_enets');
break;
}
 
}
 
function redirectPayment2(paymentMethod, paymentSubMethod) {
 
// set up inputs
document.getElementsByName("currency_code")[0].value = '{{{currency}}}';
 
if (typeof paymentSubMethod == 'undefined') {
paymentSubMethod = '';
}
var form = document.paypalcontribution; // we should really change this some day
var language = $("input[name='language']").val();
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
var params = {
'uselang' : language,
'language' : language,
'currency' : $("input[name='currency_code']").val(),
'country' : $("input[name='country']").val(),
'paymentmethod' : paymentMethod
};
if( paymentSubMethod != '' ){
params['submethod'] = paymentSubMethod;
}
// Testing for Adyen
if( paymentMethod === 'adyen-cc' ) {
paymentMethod = 'cc';
params.paymentmethod = 'cc';
params.gateway = 'adyen';
}
var frequency = $("input[name='frequency']:checked").val();
if( frequency !== 'monthly' ){
frequency = 'onetime';
} else {
params['recurring'] = 'true';
// the following is only for contribution_tracking, do not submit 'r' to payments
paymentMethod = 'r' + paymentMethod;
}
form.action = paymentsURL + '?' + $.param(params);
form.utm_source.value = '{{{banner}}}.no-LP' + '.' + paymentMethod;
form.payment_method.value = paymentMethod;
if( paymentSubMethod != '' ){
form.payment_method.value = form.payment_method.value + '.' + paymentSubMethod;
}
 
addAnalytics();
if (validateForm(document.paypalcontribution)) {
form.submit();
}
}
 
function addAnalytics () {
// this code makes sure parameters used are accessible to analytics
 
document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.';
 
if(getQuerystring( 'template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
}
 
if(getQuerystring( 'appeal-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
}
 
if(getQuerystring( 'appeal' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
}
 
if(getQuerystring( 'form-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
}
 
if(getQuerystring( 'form-countryspecific' ) == '') {
document.paypalcontribution.utm_source.value += 'control';
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
}
 
document.paypalcontribution.utm_source.value += '.' + paymentType;
document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' );
}
</script>
</html>