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

From Donate
Jump to navigation Jump to search
Content deleted Content added
explicitly set recurring=false if needed
only mess with form after validating
Line 9: Line 9:
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {


if (typeof paymentSubMethod == 'undefined') {
if ( skipValidation || validateForm(form) ) {
paymentSubMethod = '';
}
var form = document.paypalcontribution; // we should really change this some day
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';


if (typeof paymentSubMethod == 'undefined') {
form.action = paymentsURL;
paymentSubMethod = '';
}
var form = document.paypalcontribution; // we should really change this some day
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';


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


// set up inputs
if (typeof paymentSubMethod == 'undefined') {
paymentSubMethod = '';
form.currency_code.value = '</html>{{{currency|USD}}}<html>';
}


if (typeof paymentSubMethod == 'undefined') {
// WorldPay override for cc
paymentSubMethod = '';
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';
}
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;


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


// Adyen override for cc
var full_dotted_payment_method = paymentMethod;
if ( form.recurring.value == 'true' ) {
if( paymentMethod === 'cc-adyen' ) {
paymentMethod = 'cc';
full_dotted_payment_method = 'r' + full_dotted_payment_method;
form.payment_method.value = 'cc';
}
form.gateway.value = 'adyen';
if ( paymentSubMethod ) {
full_dotted_payment_method = form.payment_method.value + '.' + paymentSubMethod;
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.utm_source.value += '.' + full_dotted_payment_method;
if ( skipValidation || validateForm(form) ) {
form.method = "GET";
form.method = "GET";
form.submit();
form.submit();

Revision as of 17:27, 12 July 2016