3

I am creating a site where user could buy credits through Paypal gateway and then he could download images.

I have a confusion, I add credits in to MySQL db table while he select desired Buy Credit Package (before checkout) but I want to add them after a successful payment transaction & I don't know how I could achieve it because after paypal process I lost all information related to that user.

Thanks.

hakre
  • 193,403
  • 52
  • 435
  • 836
PHP Ferrari
  • 15,754
  • 27
  • 83
  • 149

2 Answers2

0

You have to give paypal a callback URL that holds some information about the user, like an id, username or something. After successfully closing the transaction, paypal will hit your server to that callback URL, then you'll know that the transaction was for that user

Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72
0

Put a return url like in your action form like

<input type="hidden" name="return" value="http://<?php echo $_SERVER["SERVER_NAME"] ?>/a.php"/>

all value you passed to paypal, paypal return you the same value with some additional value that is accessed by post method. In your a.php like something to get return properties...........

        $req = 'cmd=_notify-validate';
        foreach ($_POST as $key => $value) {
            $value = urlencode(stripslashes($value));
            $req .= "&$key=$value";
        }

        $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
        $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
        $fp = fsockopen ('www.paypal.com', 443, $errno, $errstr, 30);

and some other variables.

Pritom
  • 1,294
  • 8
  • 19
  • 37