Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a variable from beginning to end - Paypal

Tags:

paypal

I'be been at this for days and i cant seem to figure it out. All i want to do is when subscribe button is pushed, a variable is send ( post get i dont care ) payment is completed and landed on the success page, with my variable!

From what i can gather this should be able to do it:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="0000000">
<Input type="hidden" name="custom" value="<?php md5($code.microtime()); ?>"/>
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Any help much appreciated ( and yes I've read paypal and sandbox documentation, just not that good at reading. )

like image 331
Phil Jackson Avatar asked Jan 13 '10 08:01

Phil Jackson


1 Answers

The variables 'custom' and 'invoice' are both what PayPal calls "pass-through" variables. PayPal doesn't do anything with them, it just passes them back to you in any IPN notifications that you receive regarding that transaction (someone makes a payment, a chargeback, etc).

I can confirm personally that this works correctly as of right now using the 'custom' variable. I am using their Standard (free) payment solution currently...

How are you monitoring the IPN notification to see what variables are being posted back to you?

Edit - Additional Info Added Below:

I wanted to expand on this a bit as I was very recently caught by an issue related to pass-through variables!

The 'invoice' variable must be UNIQUE per transaction; PayPal will only allow 1 completed payment to come through per UNIQUE invoice string. Any subsequent attempts to checkout (that come in with an already-paid 'invoice' variable) will immediately be shown a "This invoice was already paid for." message.

The 'custom' variable on the other hand is NOT required to be unique and is intended to strictly be used as a pass-through variable - in most cases this is what you want to use when you're just looking for the 'pass-through' functionality.

Hope that helps - the uniqueness issue recently cost me nearly a full day of a broken checkout process on a personal project of mine!

like image 127
ArthurD Avatar answered Jan 11 '23 10:01

ArthurD