PDA

View Full Version : adding a custom element to paypal direct checkout


russell_m89943
04-16-2009, 12:21 PM
This is a bit of a hack I realize but I'd like to add an extra field to the data being sent to paypal that would hold a reference to where the shopper found the store (magazine ad, website, search engine, etc). I was thinking I could somehow tack it on to the end of the merchandise loop in the checkout page where the user is filling out their billing/shipping info. I'm also quite happy to throw it into any existing optional fields paypal direct payment pro has available if that makes it easier.

Anyone out there have enough experience with paypal pro and eCart to guide me through something like this? If possible I'd prefer to just hand code the change in there, I find changing existing eCart configs tends to mysteriously break things.

Ray Borduin
04-16-2009, 12:25 PM
You could probably find the description on the confirm page and add it by hand fairly easily. Just find a logical field to append it to and add it there.

russell_m89943
04-16-2009, 12:28 PM
I'm not actually using the confirm page at the moment but if that's the easiest way to do it then I'm happy to add that in. I should mention I'm adding the eCart functionality one page at a time, as I found the wizard did all sorts of weird things for me. (mac on CS4 is anyone is keeping track)

Ray Borduin
04-16-2009, 12:29 PM
It is wherever your local checkout server behavior is applied. That is the page where the wizard applies it.

russell_m89943
04-16-2009, 01:03 PM
I'm trying the following:

$PP_DirectPayment_itemized[0][0] = "OrderTotal";
$PP_DirectPayment_itemized[1][0] = "".$bellaCart->GrandTotal() ."";
$PP_DirectPayment_itemized[0][1] = "OrderDescription";
$PP_DirectPayment_itemized[1][1] = "".((isset($_POST["country"]))?$_POST["reference"]:"") ."";
while ( !$bellaCart->EOF() ) {

"reference" being the form field I want to grab the info from.
I purposely made the submission fail to look at the submission and lucky me, the request string contains that fields info. I'm assuming that data is present somewhere in the paypal records, even though it's not showing up anywhere in the email notification. (this is all sandbox right now)

Guess I replied to say thanks for the tip and to pass on some knowledge should anyone else need this hack.

Sorta related question: Let's say I wanted to add a confirmation page before sending to paypal. How would one go about doing that manually without breaking the eCart code?

Ray Borduin
04-16-2009, 01:07 PM
This page would actually become the confirmation page. You would make all of the form elements hidden and then create another checkout page that has the visible form that is filled out.

Then populate the hidden form on this page with the values from the form on the previous page so that they are automatically the values in this form which you already have working.

PS although your code may work, the code would more properly be:
$PP_DirectPayment_itemized[1][1] = "".((isset($_POST["reference"]))?$_POST["reference"]:"") ."";

russell_m89943
04-16-2009, 01:11 PM
Thanks, I changed the code to what you suggested, I'm a bit rusty at PHP at the moment, I'm just waking up from a long trip into objective-c and the syntax change is bending my brain ;-)

russell_m89943
04-16-2009, 02:42 PM
Hmmmm, new roadblock:

changed my original checkout page to a confirmation page by leaving everything alone with the exception of changing the forms to "hidden"

Created a new checkout form page that links to the above page. Weirdly enough when I point to this page it seems like the form is auto-submitting and the user gets no chance to review their information.

EDIT:
So I see what's going on, this line is running the minute the page is requested
if ($_SERVER["REQUEST_METHOD"] == "POST") {

Is there a way around this?

Ray Borduin
04-16-2009, 03:39 PM
Use the button press trigger instead of the any form submit trigger...

something like:
if (((isset($_POST["yourButtonName"]))?$_POST["yourButtonName"]:"") != "") {

russell_m89943
04-17-2009, 01:55 PM
Pretty close but that particular syntax didn't work, I had to add an _X to it like this:

if (((isset($_POST["paypal_x"]))?$_POST["paypal_x"]:"") != "") {

(where "paypal" is the name of my submit button)

Thanks for the lead though!

Ray Borduin
04-17-2009, 02:15 PM
I should have mentioned you need to add _x if you are using an image button and not a standard submit button.