Writing Into Db After PayPal Integration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yoursanjay
Forum Newbie
Posts: 17
Joined: Sat Feb 23, 2008 12:21 pm

Writing Into Db After PayPal Integration

Post by yoursanjay »

[font="Verdana"]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?[/font]

Code: Select all

 
$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" />    
 
 
Last edited by Benjamin on Tue May 05, 2009 1:14 pm, edited 1 time in total.
Reason: Changed code type from text to php.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Writing Into Db After PayPal Integration

Post by mattpointblank »

Check PayPal's documentation - when they send users to your thankyou.php page, do they include any $_POST or $_GET values? If not, you should look into using PayPal's IPN system, which sends $_POST variables about the payment to a script on your server, which can insert the relevant rows to your database when accessed instead.
Post Reply