Bad hack to detect PayPal or 3rd Party from PPPlus Paywall

MStephan
Contributor
Contributor

A lot of people stumble over the problem, that they don't have a clue, how to determine the chosen payment type.

I helped myself with one of my worst hacks ever:

 

 

 

 

"thirdPartyPaymentMethods":
[
{"redirectUrl":"<a href="http://projects.test/checkout5.html" target="_blank">http://projects.test/checkout5.html</a>",
"methodName": "DHL Cash on delivery (+5.95 EUR)",
"description": ""},
{"redirectUrl":"<a href="http://projects.test/checkout5.html" target="_blank">http://projects.test/checkout5.html</a>",
"methodName": "Cash up front",
"description": ""}]

 

 

 

 

Ok, now we could add two listeners to the code.
One listener is for selecting a 3rd party option, the other for deselecting.
Unfortunately the select-listener won't fire, if i pick a PayPal Option.
The deselect-listener fires always, but after the select.
Ok, bad hack, here it comes:

 

 

 

 

"onThirdPartyPaymentMethodSelected": function (data) { setTimeout(SetPayType,100,data['thirdPartyPaymentMethod']); },
"onThirdPartyPaymentMethodDeselected": function (data) { document.forms[0].PayType.value='P'; },

 

 

 

 

I need the Payment-Type in my HTML-Variable "PayType".
So i put this everytime on "P" (PayPal)

The Select event will be delayed by 100ms and calls the nice function "SetPayType":

 

 

 

 

function SetPayType(method)
	{
	var d = document.forms[0].PayType;
	d.value='P'; // Preset PayPal again
	if (method == 'DHL Cash on delivery (+5.95 EUR)') d.value = 'N';
if (method == 'Cash up front') d.value = 'V';
	};

 

 

 

 

 

I know, that's more than crazy, but works like charm and was the only solution i came up with after three full working days...

Anyone with a better solution?

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.