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

From Donate
Jump to navigation Jump to search
(remove paypal_ec override for Japan, it's default everywhere now)
 
(34 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
 
document.getElementsByName("currency_code")[0].value = '{{{currency}}}';
 
 
if (typeof paymentSubMethod == 'undefined') {
 
paymentSubMethod = '';
 
}
 
var form = document.paypalcontribution; // we should really change this some day
 
 
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
 
 
var params = {
 
'uselang' : $("input[name='language']").val(),
 
'language' : $("input[name='language']").val(),
 
'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.payment_method.value = paymentMethod;
 
if( paymentSubMethod != '' ){
 
form.payment_method.value = form.payment_method.value + '.' + paymentSubMethod;
 
}
 
 
addAnalytics();
 
 
if (validateForm(document.paypalcontribution)) {
 
 
form.submit();
 
form.submit();
 
}
 
}
}
+
};
   
function addAnalytics () {
+
donationForm.addAnalytics = function() {
 
// stuffs parameters into utm_source to make them available for analytics
 
// stuffs parameters into utm_source to make them available for analytics
   
Line 148: Line 108:
 
}
 
}
   
form.utm_source.value += '.' + form.payment_method.value;
 
 
form.utm_campaign.value = getQuerystring( 'utm_campaign' );
 
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>
 
</script>
 
</html>
 
</html>

Latest revision as of 18:19, 8 March 2018