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

From Donate
Jump to navigation Jump to search
(Created page with "<html> <script> function redirectPayment (legacyPaymentMethod) { // wrapper for redirectPayment2() // using old method parameters // until buttons can be updated ...")
 
(remove paypal_ec override for Japan, it's default everywhere now)
 
(35 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<html>
 
<html>
 
<script>
 
<script>
  +
var donationForm = {};
  +
 
function redirectPayment (legacyPaymentMethod) {
 
function redirectPayment (legacyPaymentMethod) {
  +
return undefined;
// wrapper for redirectPayment2()
 
  +
}
// using old method parameters
 
// until buttons can be updated
 
   
  +
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
switch (legacyPaymentMethod) {
 
case 'cc':
 
redirectPayment2('cc');
 
break;
 
   
  +
var form = document.paypalcontribution; // we should really change this some day
case 'paypal':
 
case 'pp':
+
  +
if ( skipValidation || validateForm(form) ) {
case 'ew-pp':
 
case 'ew-rpp':
 
case 'ew-pp-usd':
 
case 'ew-pp-eur':
 
redirectPayment2('paypal');
 
break;
 
   
case 'dd':
+
if (typeof paymentSubMethod == 'undefined') {
redirectPayment2('dd');
+
paymentSubMethod = '';
break;
+
}
  +
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
   
case 'rtbt-id':
+
form.action = paymentsURL;
redirectPayment2('rtbt', 'rtbt_ideal');
 
break;
 
   
case 'ew-yd':
+
// set up inputs
  +
form.currency_code.value = '</html>{{{currency|USD}}}<html>';
redirectPayment2('ew', 'ew_yandex');
 
break;
 
   
case 'rtbt-sf':
+
if (typeof paymentSubMethod == 'undefined') {
redirectPayment2('rtbt', 'rtbt_sofortuberweisung');
+
paymentSubMethod = '';
break;
+
}
   
case 'ew-amazon':
+
// WorldPay override for cc
redirectPayment2('amazon');
+
if( paymentMethod === 'cc-wp' ) {
break;
+
paymentMethod = 'cc';
  +
form.payment_method.value = 'cc';
  +
form.gateway.value = 'worldpay';
  +
form.ffname.value = 'worldpay';
  +
}
   
case 'obt-bp':
+
// Adyen override for cc
redirectPayment2('obt', 'bpay');
+
if( paymentMethod === 'cc-adyen' ) {
break;
+
paymentMethod = 'cc';
  +
form.payment_method.value = 'cc';
  +
form.gateway.value = 'adyen';
  +
form.ffname.value = 'adyen';
  +
}
   
  +
var frequency = $("input[name='frequency']:checked").val();
case 'ew-wm':
 
redirectPayment2('ew', 'ew_webmoney');
+
if( frequency !== 'monthly' ){
break;
+
frequency = 'onetime';
  +
form.recurring.value = 'false';
  +
} else {
  +
form.recurring.value = 'true';
  +
}
   
  +
form.payment_method.value = paymentMethod;
case 'cash-bl':
 
  +
form.payment_submethod.value = paymentSubMethod;
redirectPayment2('cash', 'boleto');
 
break;
 
   
case 'rtbt-en':
+
donationForm.addAnalytics();
redirectPayment2('rtbt', 'rtbt_enets');
 
break;
 
}
 
   
  +
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;
function redirectPayment2(paymentMethod, paymentSubMethod) {
 
   
  +
form.method = "GET";
// set up inputs
 
  +
form.submit();
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;
 
 
}
 
}
  +
};
   
  +
donationForm.addAnalytics = function() {
addAnalytics();
 
  +
// stuffs parameters into utm_source to make them available for analytics
 
if (validateForm(document.paypalcontribution)) {
 
form.submit();
 
}
 
}
 
   
  +
var form = document.paypalcontribution;
function addAnalytics () {
 
// this code makes sure parameters used are accessible to analytics
 
   
document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.';
+
form.utm_source.value = getQuerystring( 'utm_source' ) + '.';
   
 
if(getQuerystring( 'template' ) == '') {
 
if(getQuerystring( 'template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
+
form.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'appeal-template' ) == '') {
 
if(getQuerystring( 'appeal-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
+
form.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'appeal' ) == '') {
 
if(getQuerystring( 'appeal' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
+
form.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'form-template' ) == '') {
 
if(getQuerystring( 'form-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
+
form.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'form-countryspecific' ) == '') {
 
if(getQuerystring( 'form-countryspecific' ) == '') {
document.paypalcontribution.utm_source.value += 'control';
+
form.utm_source.value += 'control';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
+
form.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
 
}
 
}
   
  +
form.utm_campaign.value = getQuerystring( 'utm_campaign' );
document.paypalcontribution.utm_source.value += '.' + paymentType;
 
  +
};
document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' );
 
  +
}
 
  +
donationForm.toggleMonthly = function(monthly) {
  +
if (monthly) {
  +
$('#form-wrapper').addClass('form-monthly');
  +
} else {
  +
$('#form-wrapper').removeClass('form-monthly');
  +
}
  +
};
 
</script>
 
</script>
 
</html>
 
</html>

Latest revision as of 18:19, 8 March 2018