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

From Donate
Jump to navigation Jump to search
(allow an override for worldpay)
(remove paypal_ec override for Japan, it's default everywhere now)
 
(13 intermediate revisions by 2 users not shown)
Line 9: Line 9:
 
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
 
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
   
// set up inputs
 
document.getElementsByName("currency_code")[0].value = '</html>{{{currency|USD}}}<html>';
 
 
if (typeof paymentSubMethod == 'undefined') {
 
paymentSubMethod = '';
 
}
 
 
var form = document.paypalcontribution; // we should really change this some day
 
var form = document.paypalcontribution; // we should really change this some day
  +
 
  +
if ( skipValidation || validateForm(form) ) {
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
 
 
var params = {
 
'uselang' : $("input[name='language']").val(),
 
'language' : $("input[name='language']").val(),
 
'currency_code' : $("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';
 
}
 
   
  +
if (typeof paymentSubMethod == 'undefined') {
// Worldpay
 
  +
paymentSubMethod = '';
if( paymentMethod === 'cc-wp' ) {
 
paymentMethod = 'cc';
+
}
  +
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
params.paymentmethod = 'cc';
 
  +
params.gateway = 'worldpay';
 
params.ffname = 'worldpay';
+
form.action = paymentsURL;
  +
}
 
  +
// set up inputs
 
  +
form.currency_code.value = '</html>{{{currency|USD}}}<html>';
var frequency = $("input[name='frequency']:checked").val();
 
  +
if( frequency !== 'monthly' ){
 
frequency = 'onetime';
+
if (typeof paymentSubMethod == 'undefined') {
  +
paymentSubMethod = '';
// commented out below as it breaks eNETS for some reason
 
  +
}
// params['recurring'] = 'false';
 
  +
} else {
 
  +
// WorldPay override for cc
params['recurring'] = 'true';
 
  +
if( paymentMethod === 'cc-wp' ) {
// the following causes tons of errors. Don't.
 
// paymentMethod = 'r' + paymentMethod;
+
paymentMethod = 'cc';
  +
form.payment_method.value = 'cc';
}
 
  +
form.gateway.value = 'worldpay';
 
  +
form.ffname.value = 'worldpay';
form.action = paymentsURL + '?' + $.param(params);
 
  +
}
form.payment_method.value = paymentMethod;
 
  +
if( paymentSubMethod != '' ){
 
  +
// Adyen override for cc
form.payment_method.value = form.payment_method.value + '.' + paymentSubMethod;
 
  +
if( paymentMethod === 'cc-adyen' ) {
}
 
  +
paymentMethod = 'cc';
  +
form.payment_method.value = 'cc';
  +
form.gateway.value = 'adyen';
  +
form.ffname.value = 'adyen';
  +
}
  +
  +
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";
donationForm.addAnalytics();
 
 
if (validateForm(form) || skipValidation) {
 
form.method = "POST";
 
 
form.submit();
 
form.submit();
 
}
 
}
}
+
};
   
 
donationForm.addAnalytics = function() {
 
donationForm.addAnalytics = function() {
Line 107: 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) {
 
donationForm.toggleMonthly = function(monthly) {
Line 117: Line 117:
 
$('#form-wrapper').removeClass('form-monthly');
 
$('#form-wrapper').removeClass('form-monthly');
 
}
 
}
}
+
};
 
</script>
 
</script>
 
</html>
 
</html>

Latest revision as of 18:19, 8 March 2018