Hi, I am using the following script for PayPal integration for my site. After successful transaction the page is redirected to thankyou.php page. In this page I want to store the PayPal transaction information into my db. I am passing Invoice id & user id at the time of integration. I need these two values (invoice id & userid) in thankyou.php page. How will I get these values so that i can run my sql? $userid=$_GET['userid']; $invoiceid=$_GET['invoiceid']; $cost=$_GET['cost']; $_SESSION['payment_check']=time(); <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="<?=$paypal?>" /> <input type="hidden" name="item_name" value="Invoice #<?=$invoiceid?>" /> <input type="hidden" name="amount" value="<?=$cost?>" /> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="no_note" value="1" /> <input type="hidden" name="currency_code" value="<?=$paypal_curr?>" /> <input type="hidden" name="lc" value="<?=$paypal_lang?>" /> <input type="hidden" name="at" value="xxxxxxxxxxxxxxxxxxxxxxxxx"> <input name="Custom" id="Custom" type="hidden" value="<?=$userid?>"/> <input type="hidden" name="bn" value="PP-BuyNowBF" /> <input name="sucess_return" id="sucess_return" type="hidden" value="<?=$site_url?>thankyou.php?key=<?=base64_encode($_SESSION['payment_check']."-a")?>" /> <input name="cancel_return" id="cancel_return" type="hidden" value="<?=$site_url?>cancel.php?key=<?=base64_encode($_SESSION['payment_check']."-b")?>" /> <input id="return" type="hidden" name="return" value="<?=$site_url?>thankyou.php?key=<?=base64_encode($_SESSION['payment_check']."-a")?>"> <input name="notify_url" id="notify_url" type="hidden" value="<?=$site_url?>thankyou.php?key=<?=base64_encode($_SESSION['payment_check']."-a")?>" /> <input name="paypal" type="image" src="images/button/paypal.gif" align="right" /> Code (markup):
easy way.. When IPN comes back as a completed transaction, why don't you insert the data into the DB at that time. Make a little form that the user presses a button where you can $_POST those to variables to the thank you page. not so easy way.. If you need to go to the thank you page right away, you could encrypt/hexencode those two variables and pass it to the thank you page as a $_GET.
Enable PDT(payment data transfer) from your paypal account. After that, after the payment, when paypal returns the visitor to thankyou.php page, it will send the transaction id and status in the query string to the welcome.php
I think you've got to setup a "custom" field to forward your "user_id" to paypal. When paypal is sending back the information on the "thank you page", use the $_POST['custom'] to retrieve your user_id and create the invoice at this time (and then, save it in the DB...)