1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Writing Into Db After Papal Integration

Discussion in 'PHP' started by yoursanjay, May 5, 2009.

  1. #1
    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):

     
    yoursanjay, May 5, 2009 IP
  2. darkmessiah

    darkmessiah Peon

    Messages:
    500
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    darkmessiah, May 5, 2009 IP
  3. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #3
    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
     
    MayurGondaliya, May 5, 2009 IP
  4. Anto1982

    Anto1982 Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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...)
     
    Anto1982, May 8, 2009 IP