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

From Donate
Content deleted Content added
No edit summary
remove paypal_ec override for Japan, it's default everywhere now
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<html>
<html>
<style>
/* temporary to indicate this is the beta code. REMOVE when in production use */
#donate-form-wrapper {
background: #ffff00 !important;
}
</style>
<script>
<script>
donationForm = {};
var donationForm = {};


function redirectPayment (legacyPaymentMethod) {
function redirectPayment (legacyPaymentMethod) {
return undefined;
// wrapper for new function
}
// using old method parameters
// until buttons can be updated


donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
switch (legacyPaymentMethod) {
case 'cc':
donationForm.redirectPaymentWithSubMethod('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':
donationForm.redirectPaymentWithSubMethod('paypal');
break;


case 'dd':
if (typeof paymentSubMethod == 'undefined') {
donationForm.redirectPaymentWithSubMethod('dd');
paymentSubMethod = '';
break;
}
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';


case 'rtbt-id':
form.action = paymentsURL;
donationForm.redirectPaymentWithSubMethod('rtbt', 'rtbt_ideal');
break;


case 'ew-yd':
// set up inputs
form.currency_code.value = '</html>{{{currency|USD}}}<html>';
donationForm.redirectPaymentWithSubMethod('ew', 'ew_yandex');
break;


case 'rtbt-sf':
if (typeof paymentSubMethod == 'undefined') {
paymentSubMethod = '';
donationForm.redirectPaymentWithSubMethod('rtbt', 'rtbt_sofortuberweisung');
break;
}


case 'ew-amazon':
// WorldPay override for cc
if( paymentMethod === 'cc-wp' ) {
donationForm.redirectPaymentWithSubMethod('amazon');
break;
paymentMethod = 'cc';
form.payment_method.value = 'cc';
form.gateway.value = 'worldpay';
form.ffname.value = 'worldpay';
}


case 'obt-bp':
// Adyen override for cc
if( paymentMethod === 'cc-adyen' ) {
donationForm.redirectPaymentWithSubMethod('obt', 'bpay');
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':
if( frequency !== 'monthly' ){
donationForm.redirectPaymentWithSubMethod('ew', 'ew_webmoney');
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;
donationForm.redirectPaymentWithSubMethod('cash', 'boleto');
break;


case 'rtbt-en':
donationForm.addAnalytics();
donationForm.redirectPaymentWithSubMethod('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;
donationForm.redirectPaymentWithSubMethod = function(paymentMethod, paymentSubMethod) {


form.method = "GET";
// 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 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';
// commented out below as it breaks eNETS for some reason
// params['recurring'] = 'false';
} 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;
}

donationForm.addAnalytics();
if (validateForm(form)) {
form.method = "POST";
form.submit();
form.submit();
}
}
}
};


donationForm.addAnalytics = function() {
donationForm.addAnalytics = function() {
Line 159: 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>

Revision as of 18:19, 8 March 2018