Payment System with Paypal
Wall Script
Follow Me:
Monday, March 14, 2011

Payment System with Paypal

I received a tutorial requests from my reader that asked to me how to implement payment gateway system with Paypal API. In this post I want to explain how to work with Paypal Sandbox test accounts for payment system development and sending arguments while click buy now button. It’s simple and very easy to integrate in your web projects.

Payment System

Download Script     Live Demo

Sample database design for Payment system. Contains there table users, products and sales.
Payment process database design

Users
CREATE TABLE `users` (
`uid` int(11) AUTO_INCREMENT PRIMARY KEY,
`username` varchar(255) UNIQUE KEY,
`password` varchar(255),
`email` varchar(255) UNIQUE KEY,
)

Products
CREATE TABLE `products`
(
`pid` int(11) AUTO_INCREMENT PRIMARY KEY,
`product` varchar(255),
'product_img` varchar(100),
`price` int(11),
`currency` varchar(10),
 )

Sales
CREATE TABLE `sales`
(
`sid` int(11) AUTO_INCREMENT PRIMARY KEY,
`pid` int(11),
`uid` int(11),
`saledate` date,
`transactionid` varchar(125),
FOREIGN KEY(uid) REFERENCES users(uid),
FOREIGN KEY(pid) REFERENCES products(pid)
)


Step 1
Create a Paypal Sandbox account at https://developer.paypal.com/

Step 2
Now create test accounts for payment system. Take a look at Sandbox menu left-side top Sandbox->Test Accounts
Creating Paypal Test Account

Step 3
Here I have created two accounts Buyer (personal) and Seller (merchant/business)
Paypal test accounts

products.php
Contains PHP code. Displaying records from products table product image, product name and product price. Here you have to give your business(seller) $paypal_id id. Modify paypal button form return and cancel_return URLs.
<?php
session_start();
require 'db_config.php';
$uid=$_SESSION['uid'];
$username=$_SESSION['username'];
$paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
$paypal_id='your_seller_id'; // Business email ID
?>

<body>
<h2>Welcome, <?php echo $username;?></h2>
<?php
$result = mysql_query("SELECT * from products");
while($row = mysql_fetch_array($result))
{
?>
<img src="images/<?php echo $row['product_img'];?>" />
Name: <?php echo $row['product'];?>
Price: <?php echo $row['price'];?>$
// Paypal Button 
<form action='<?php echo $paypal_url; ?>' method='post' name='form<?php echo $row['pid']; ?&gt;'>
<input type='hidden' name='business' value='<?php echo $paypal_id; ?>'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='item_name' value='<?php echo $row['product'];?>'>
<input type='hidden' name='item_number' value='<?php echo $row['pid'];?>'>
<input type='hidden' name='amount' value='<?php echo $row['price'];?>'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='cancel_return' value='http://yoursite.com/cancel.php'>
<input type='hidden' name='return' value='http://yoursite.com/success.php'>
<input type="image" src="https://paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit">
</form>


<?php
}
?>
</body>

success.php
Paypal payment success return file. Getting Paypal argument like item_number. Paypal data success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1
<?php
session_start();
require 'db_config.php';
$uid = $_SESSION['uid'];
$username=$_SESSION['username'];
$item_no = $_GET['item_number'];
$item_transaction = $_GET['tx']; // Paypal transaction ID
$item_price = $_GET['amt']; // Paypal received amount
$item_currency = $_GET['cc']; // Paypal received currency type

//Getting product details
$sql=mysql_query("select product,price,currency from producst where pid='$item_no'");
$row=mysql_fetch_array($sql);
$price=$row['price'];
$currency=$row['currency'];

//Rechecking the product price and currency details
if($item_price==$price && item_currency==$currency)
{

$result = mysql_query("INSERT INTO sales(pid, uid, saledate,transactionid) VALUES('$item_no', '$uid', NOW(),'$item_transaction')");
if($result)
{
echo "<h1>Welcome, $username</h1>";
echo "<h1>Payment Successful</h1>";
}
}
else
{
echo "Payment Failed";
}
?>

Positive approach


cancel.php
Paypal API cancel_return file.
<?php
session_start();
$username=$_SESSION['username'];
echo "<h1>Welcome, $username</h1>";
echo "<h1>Payment Canceled</h1>";
?>

Negative approach


Step 4
When your web application test payment system workflow is completed. Change the form action development API URLs to original API URLs and give valid $paypal_id seller email id.
$paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr';
to
$paypal_url='https://www.paypal.com/cgi-bin/webscr';

Was this article helpful?
Thanks! Your feedback helps us to improve 9lessons.info


182 comments:

  1. nice, i have some project that needed to integrate with PP, and you make this tuts :)

    great :)

    ReplyDelete
  2. nice !! :-) ... you are a genius ... you always make complicated things easier ...

    ReplyDelete
  3. How we can get the commission for each sales.. mean if some one sells any products using my website i need to take 5% from the total amount of the product. How it can be done in Paypal. so that 5% amount is automatically transferred to my paypal account.

    ReplyDelete
  4. Hi srini, nice tute as usual..:) is creating test account on paypal free or payable?

    ReplyDelete
  5. Srinivas, I'm curious about your database graph. What do you use when designing databases?

    ReplyDelete
  6. Hey Great tutorial, Srinivas, thank you from PerĂº.

    ReplyDelete
  7. Omg.... Asians rock!

    ReplyDelete
  8. Great post Srinivas... we like these kind of innovative posts. Thanks a lot.

    ReplyDelete
  9. SQL Injection, no verification that a call to success.php actually came from PayPal (and is valid)...words fail me.

    ReplyDelete
  10. this tutorial ROCKS! thank you very much dude :D

    ReplyDelete
  11. @Dan Mysql Workbench for database ER diagrams.

    ReplyDelete
  12. waw..thanks for sharing Srinivas..:)

    ReplyDelete
  13. You have a big logical error in your code. You don't check what your code in success.php called from PayPal. Anyone can create html file (at the his own PC) with code like next:
    <--FORM action="yoursite/success.php">
    <--input type="text" name="item_number" value="Item1">
    <--input type="submit"><--/FORM>.
    This code calls to your page success.php and send there "item_number=Item1". And your page thinks what PayPal payment is accepted. But operation performed without PayPal.

    ReplyDelete
  14. thanks for sharing, paypal API is actually pretty complicated because there are too many options. We faced these issues while doing the integrations for http://www.mobikwik.com

    ReplyDelete
  15. hi,

    i tried your code and it worked fine for me, the only error i got is i am not getting the product id after successful transaction and getting "Payment Error" while inserting record in database...

    ReplyDelete
  16. Hey Srini,
    i got the same error like ashish...

    ReplyDelete
  17. Nice post. I solved my problem very well.

    Thanks

    ReplyDelete
  18. Modified 'success.php' file code. Re-checking the product price and currency details

    ReplyDelete
  19. hi srini, my question is .. in step 1 we need to register for the sandbox account.. is it paid account ??

    ReplyDelete
  20. @Sreevathsa

    It's free just test account

    ReplyDelete
  21. hey Sri its not TEXT ACCOUNT its TEST Brother I think a little typo mistake is there.. :)

    ReplyDelete
  22. i am confused - cant anyone just call the success.php page and post sales? Usually I would assume you need to use PayPal IPN or something - its a good example but I am not sure if this is practical?

    ReplyDelete
  23. For me its not safe, also the return url dont have transaction id for me.

    ReplyDelete
  24. Very Handy tuts :)

    ReplyDelete
  25. item_number. Paypal data success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1

    what $_GET[???], is Quantity???

    ReplyDelete
  26. its post is nice but why are you using IPN for update database.

    ReplyDelete
  27. Please advice how to use this tutorail to protect digital file. if success able to download file if not protected digital file.

    ReplyDelete
  28. Hi. Thanks for the tutorial. Everything works fine, except the redirection to the success page after the payment. Paypal doesn't redirect, it only confirms the payment and shows a link: Back to Robert Kleinert's Teststore. When I click on that link Paypal redirects to success.php?merchant_return_link=Back+to+Robert+Kleinert's+Test+Store

    Whats the problem here? Or is it only a sandbox problem?

    Thanks.

    ReplyDelete
  29. Dear Srinivas Tamada,

    i have downloaded import database o.k, tested o.k all, only url of success it still success.php not added more params. did you shared not enought code ? please check. i'm trying with ipn and use curt of php to test with more code.

    ReplyDelete
  30. Same with Nguyen Hai Dang

    ReplyDelete
  31. Sanbox new accounts success redirection problem.

    ReplyDelete
  32. It was helpfull for me, however I think it is insecure to rely just on the data sent to the success.php file to verify the sale.

    I added a field named 'verified' to the Sales table which defaults to '0'.
    I then created a ipn.php file that is called by Paypal once the payment is received. This file then searches for the correct transactionid already on the table and changes the value of 'verified' to '1'.

    This way you know the payment is legit because it's confirmed by Paypal itself. Otherwise people can just call the success.php directly and insert fake payments.

    I think that having this is enough to make the process secure. Do you guys know of anything else I might be missing?

    ReplyDelete
  33. @Nguyen Hai dang

    I had the same issue, add this to the process form:
    input type='hidden' name='return_method' value='2'

    This defines the method that is used to pass the params to success.php (1=GET, 2=POST). I think GET is the default but it wasn't working for me so I changed to POST and it now receives the data.

    ReplyDelete
  34. Hi,
    Can you Please tell is there any script which can convert smarty files to core php files instead of doing manually it is taking lot of time to change the code manually.If you have any solution Please let me know soon.........

    waiting for your response.........

    ReplyDelete
  35. I tried this demo.. working well, but when i tried the downloaded code, and customised it with my own details, i see that the payment is done.. but when it comes back to success.php, there is no parameter passed, and i receive the message: Payment Failed. Could not understand what is wrong.

    ReplyDelete
  36. @dskanth

    Paypal Sanbox creating some problem with new registration accounts. Success page not redirecting well try to use my test merchant email.

    ReplyDelete
  37. thank you from LA. great tutorial!

    ReplyDelete
  38. Awsome tutorial it wrks in my web, buti need to pay several products but it only sends one, how can i do it?

    ReplyDelete
  39. Man I Love your Blog its fantastic what you explain here im not well in english language but everything is clearly for me thanks for this blog man.

    ReplyDelete
  40. hi dear Srinivas Tamada
    its very use full tutorial for me thanks but i am having problem on succes.php page because when its return from paypal page it show me payment failed and data also not inserting in database please do tell me the solution as soon as possible i am waiting. thanks

    ReplyDelete
  41. and i want to know that if a user buy shirt on index page i will show him 0 value but when he came back after payment i want to show value 1 how it will done please tell

    ReplyDelete
  42. will you please tell me how it will done??
    i want to show a "0" value in label when user comes first time on my site and after payment through paypal when he or she back on my site on i want to show a value "1" in label kindly help me as soon as posible
    thanks

    ReplyDelete
  43. Maybe must add feature to download product and expired download link..

    Thanks

    ReplyDelete
  44. Hi,

    Nice tutorial it work properly when i set my return url: http://demos.9lessons.info/paypal/success.php.
    But when i change it with my url for ex:
    return url: http://localhost/paypal/success.php.

    it not work properly i am also not getting any item_no value on the success.php file when i echo the query :
    "select product,price,currency from producst where pid='$item_no'"
    it give pid=''

    what is the problem .
    Please provide me a solution for it.

    ReplyDelete
  45. Hi Srinivas,

    i send a feed back to you regarding this tutorial . It was my mistake. It working fine with your $paypal_id ='sriniv_1293527277_biz@inbox.com' but when i use my pay pal id marut_1321421584_biz@1solutions.biz

    It not work properly what is the issue. Can anything we do in my pay-pal sand box account setting.

    in this case we not get item_number and amt and all other thing what is the problem .

    Please provide me the solution for it.

    My mail id is marut0210@gmail.com

    ReplyDelete
  46. Hi, In my case, the user is not redirected back to my website after payment is completed. Is there another back end soluction to get notified of a transaction? I'm trying to configure IPN but I cannot find it on sandbox anymore.

    ReplyDelete
  47. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\paypal\success.php on line 15
    Payment Failed

    ReplyDelete
  48. hi, Srinivas thanks for your tutorial.
    it's great for me. First of all i had been the problem as @ashutosh Mishra too. now i can find the solution to redirect to the success.php page.
    1. log in into Business mail
    2. click on profile
    3. Website payment preferences
    in that, configure some points:
    set Auto Return to On and type return URL address (e.g. http://localhost/paypal/success.php)
    set Payment Data Transfer to On

    I'm sorry if my English made you misunderstand.

    ReplyDelete
  49. really good to see this blog...
    I need one help from how can i create test account for money booker payment gateway..

    ReplyDelete
  50. hi,i used your code but after transaction,i did not get any txnid,amount will you plz help me..i got message payment failed....

    ReplyDelete
  51. Hi

    In my PayPal sandbox account, when I click "Pay Now" it display a link "Return to my Test Store".
    But I want sandbox get the process of auto return.
    Can we do this with PayPal Sandbox?

    ReplyDelete
  52. @ Srinivas,

    I follow your code already. after user payed, the paypal did not redirect to my website so I can not get the transactionID, amount...

    I tested with sanbox. Please help me.

    ReplyDelete
  53. Hi Srinivas,

    It works fine with your $paypal_id ='sriniv_1293527277_biz@inbox.com' but when i use my email It not work properly what is the issue.
    How can I get the paypaID? Do I need to config with paypal account setting?

    Please provide me the solution with this problem.

    ReplyDelete
  54. Hi Seyha

    Paypal sandbox updated new sample biz id not redirecting properly.

    ReplyDelete
  55. Hi, I used it but it live for Paypal Send box but it only show
    Thanks for your order page of Paypal, not redirect to success.php and therefore does not insert record into sales table.

    ReplyDelete
  56. Hi, your code helped me to start my code with.
    Facing a problem! What if a user clicks some other link (like: show my account details); our site will not be notified about payment and the payment will b deducted from user account and credited to store account. BUT our database will have no entry against it.
    Any solution??

    ReplyDelete
  57. OMG, you save my time, thanks. love this tutorial.

    ReplyDelete
  58. Hi Srinivas Tamada,
    I 'm Ok all of the steps,but in success.php it show me "Payment Failed" and it does not save sales table. Why? . That's a problem and please explain it. Thanks in advance.

    ReplyDelete
  59. Hi!
    so the redirection problem is there in the sandbox accounts

    but is the redirection problem also in the real accounts...

    can some confirm this..

    @Srinivas: awesum blog... really helped..
    \m/

    ReplyDelete
  60. Hi Srinivas,

    when i used your paypal id , paypal will redirect to success page(all working fine) but when i use my paypal id it's not redirect! so how to update my database?

    ReplyDelete
  61. When I do this, and paypal returns to the return url it does not post the info to the url like this "success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1"
    it just goes to "success.php" why is that?

    ReplyDelete
  62. @Gurav, this is something I also want to know

    ReplyDelete
  63. Is it possible to pay the amount to two account at a single time?

    I mean to say that when a person pays amount then his amount will be divided in two parts 95% of amount to the actual payment receiver and 5% to a default user(me).

    ReplyDelete
  64. need to explain more clearly dear

    ReplyDelete
  65. I am getting the following error
    This recipient is currently unable to receive money
    What should i do

    ReplyDelete
  66. Hay First of all thanks dude...
    I try your demo code and its work properly but in final step i can't redirect on sucess.php pls replay fast...

    Thanks again..

    ReplyDelete
  67. Hi Srinivas Tamada,thank u for update
    I 'm Ok all of the steps,but in success.php it show me "Payment Failed" and it does not save sales table. Why? . That's a problem and please explain it. Thanks in advance.

    ReplyDelete
  68. Is there anyway to make it auto-redirect to the success page? Right now, the only way for their purchase to be added to the database is IF they actually click return to the website.

    ReplyDelete
  69. I actually figured out the previous redirect issue, needed to change something in my paypal settings. Now I am noticing none of the parameters are sent with the success.php so all of the info being input into the database is blank or 0. Any way to fix this so it gets the actual data?

    ReplyDelete
  70. Awesome!!!!! I never see on the web like this..!

    ReplyDelete
  71. It's excellent Srinivas.

    @Nate:

    Auto Return is turned off by default.
    To turn on Auto Return:

    Log in to your PayPal account at https://www.paypal.com. The My Account Overview page appears.

    Click the Profile subtab.
    The Profile Summary page appears.

    Under the Selling Preferences column, click the Website Payment Preferences link. The Website Payment Preferences page appears

    Under Auto Return for Website Payments, click the On radio button to enable Auto Return.

    In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments.

    NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted or cannot be validated, PayPal will not activate Auto Return.

    Scroll to the bottom of the page, and click the Save button.

    Raj

    ReplyDelete
  72. Thank You Man It Is Grate...

    ReplyDelete
  73. Really, it's amazing tutorial for us...
    Thank You....very much G...

    ReplyDelete
  74. Awesome bro.. helped me like HELL!!

    ReplyDelete
  75. Great tutorial.. Thanks a bunch!! Didn't know Paypal transactions were so easy. :D

    But it seems that the transaction ID and all are now being sent via email to the registered email address of the Paypal user. So we won't be needing the `sales` table part :D

    ReplyDelete
  76. Someone please help me i am new in php and wnt to play this paypa script but when i go to import the downloaded file paypal.sql it gives error like this:

    CREATE TABLE IF NOT EXISTS `sales` (
    `sid` int( 11 ) NOT NULL AUTO_INCREMENT ,
    `pid` int( 11 ) DEFAULT NULL ,
    `uid` int( 11 ) DEFAULT NULL ,
    `saledate` date DEFAULT NULL ,
    'transactionid'varchar( 125 ) ,
    PRIMARY KEY ( `sid` ) ,
    KEY `pid` ( `pid` ) ,
    KEY `uid` ( `uid` )
    ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =12;

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''transactionid' varchar(125),
    PRIMARY KEY (`sid`),
    KEY `pid` (`pid`),
    K' at line 12

    please help me
    i will be very thankful to all of you...

    ReplyDelete
  77. Sir i have one more problem please help me i want to create pdf filefrom the "registered.php" using FPDF CLASS LIBRARY but when click on "create pdf" button it only convert the index to pdf but not values of their indexes is displaying.....please help me...this is my conversion code..

    AddPage();
    $pdf->SetFont('Arial','B',10);

    $pdf->Ln();
    $pdf->Ln();

    $pdf->SetFont('Arial','B',10);
    $pdf->Cell(20,15,"No");
    $pdf->Cell(20,15,"name");
    $pdf->Cell(20,15,"dob");
    $pdf->Cell(20,15,"email");
    $pdf->Cell(20,15,"address");
    $pdf->Cell(20,15,"mobile");
    $pdf->Cell(15,15,"gender");
    $pdf->Cell(20,15,"country");
    $pdf->Cell(20,15,"city");
    //$pdf->Cell(20,15,"remarks");
    $pdf->Cell(20,15,"image");
    $pdf->Ln();
    $pdf->Cell(1050,3,"--------------------------------------------------------------------------------------------------------------------------------------------------------");

    $query = "SELECT * FROM register_user";
    $result = mysql_query($query, $db) or die(mysql_error());
    //$row = mysql_fetch_assoc($result);
    //$totalRows_rsReportData = mysql_num_rows($result);
    $No = 0;

    while($row=mysql_fetch_assoc($result))
    {
    $No = $No + 1;
    $name = $row['name'];
    $dob = $row['dob'];
    $email = $row['email'];
    $address= $row['address'];
    //$mobile = $row['mobile'];
    //$gender = $row['gender'];
    //$country= $row['country'];
    //$city = $row['city'];
    //$remarks= $row['remarks'];
    //$image = $row['image'];
    $pdf->Cell(5,15,"{$No}");
    $pdf->Cell(20,15,"{$name}");
    $pdf->Cell(20,15,"{$dob}");
    $pdf->Cell(20,15,"{$email}");
    $pdf->Cell(20,15,"{$address}");
    //$pdf->Cell(20,15,"{$mobile}");
    //$pdf->Cell(15,15,"{$gender}");
    //$pdf->Cell(20,15,"{$country}");
    //$pdf->Cell(20,15,"{$city}");
    //$pdf->Cell(20,15,"{$remarks}");
    //$pdf->Cell(20,15,"{$image}");
    foreach($row as $value)
    {
    //echo $value;
    }

    }

    $pdf->Output();
    ?>

    ReplyDelete

  78. How to fix this error

    Undefined index: item_number in C:\wamp\www\mvc\view\success.php on line 13

    Undefined index: tx in C:\wamp\www\mvc\view\success.php on line 14

    Undefined index: amt in C:\wamp\www\mvc\view\success.php on line 15

    Notice: Undefined index: cc in C:\wamp\www\mvc\view\success.php on line 16

    ReplyDelete
  79. any Help is apperciatable
    Why this one

    Notice: Undefined index: item_number \success.php on line 17

    Notice: Undefined index: tx in

    Notice: Undefined index: amt in C:\xampp\htdocs
    Notice: Undefined index: cc in C:\xampp\htdocs\cubexsweatherly\paypal_lesson\success.php on line 20

    ReplyDelete
  80. please tell me how to turn on Auto Return for testing account?i have created 2 account as business and personal as preconfigured accounts.

    ReplyDelete
  81. another error on success php

    if($item_price==$price && item_currency==$currency)

    item_currency is missing a $

    ReplyDelete
  82. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\paypal(2.0)\products.php on line 40

    getting this error pls help

    ReplyDelete
  83. All went perfectly..just one error while returning from paypal page.Got following error:
    The requested URL /paypal/success.php was not found on this server.

    Thanx for d tutorial

    ReplyDelete
  84. Hi

    When i tried live demo from my browser its showing https://www.sandbox.paypal.com/cgi-bin/webscr page only reset of the things not coming , could you please advise any thing i missed out.

    ReplyDelete
  85. This code can't user for production site.Use Paypal IPN to receive payment notification.

    http://code.google.com/p/paypal-ipn-class-php/

    ReplyDelete
  86. Man you saved my life many times already! :D

    ReplyDelete
  87. i am using the same code as mentioned but i my success url transactiion id is not coming .. what to do ?
    please help

    ReplyDelete
  88. I am not getting the transction id after successful payment..
    what to do ?

    please help

    ReplyDelete
  89. Hi shirni..
    I am using same code as you write in above post. But I am not receiving any parameters in my url. So can you please help me in this problem?

    ReplyDelete
  90. not working for me. redirect url not passing data.. Please help me

    ReplyDelete
  91. i had the same issue with paypal not auto returning or getting data about transaction.

    if you log into your sandbox Seller account. click on profile and go to 'selling preferences' then in the list click on 'Website Payment Preferences' in here you have a few options, you need to set Auto Return to ON also make sure Payment Data Transfer is set to ON - this will give you the transaction id, the amount etc.

    ReplyDelete
  92. forgot to say thanks @Srinivas Tamada :D

    ReplyDelete
  93. can't get the transaction number..when back to sucess.php please help...

    ReplyDelete
  94. How to pass other custom values to paypal... because i want to save more than 5 values in success.php from client

    ReplyDelete
  95. thanks for the tutorial, i have a problem on success.php i get Payment Failed. and am using sandbox accounts where i can't selling preferences to configure auto-return urls.

    if any would help me i would be greatful

    ReplyDelete
  96. hi !

    I am already used your paypal payment system.used send box system.payment successfully transfer one paypal to another paypal account.but database dont updated the payment transaction. please help me how to solve the problem.I am already follow your direction. But I cant solve.please help me.

    ReplyDelete
  97. i found this very informative thanks for sharing..

    ReplyDelete
  98. hi i liked ur post a lot and was helpful too.can u provide same example in jsp?

    ReplyDelete
  99. this was very helpful thanks but can u give same example in jsp?

    ReplyDelete
  100. hi and one more thin i tried ur code myself in jsp the prob with it lik u shown in live demo wen one clicks buy button it takes them to login for sandbox and shows order summary,but in mine its not showing tat.its just showing login to continue.and don display order summary.

    ReplyDelete
  101. Hi thank to share this video but i need paypal recurring payment method and get response with profile id. After that i want run cron on profile id to know this paypal is done or not every month..

    ReplyDelete
  102. we are going to use it in our classified sites...
    A great way for transaction

    ReplyDelete
  103. Hi this is a great tutorial, quick thing i've got my sandbox set up and all working but when someone makes a payment it is going through ok on paypal but when you are directed back to the website its says payment failed. the information from paypal is not coming back to the website. Any ideas?

    ReplyDelete
  104. how to get responce automaticly from paypal ? plese explain

    ReplyDelete
  105. can you please expalin how to get responce automaticly on sucess.php or how to show all payment detail on own website page after payment ?

    ReplyDelete
  106. I get this error:


    Parse error: syntax error, unexpected '?' in C:\Program Files\EasyPHP-12.1\www\my portable files\GotMerch\New Folder\products.php on line 21


    Whats going on there like?

    ReplyDelete
  107. I'm impressed with the way you have condensed pages and pages of PayPal bumff into this concise and easily understood article! Well done!
    P.S. Could you possibly explain how we can integrate a site to include credit card payment via PayPal? Not all our visitors have PayPal Accounts, but they do have credit cards...

    ReplyDelete
  108. nice code, this really help me

    ReplyDelete
  109. need help
    its work fine with your $paypal_id ='sriniv_1293527277_biz@inbox.com' but when i use my email It not work properly what is the issue.
    in previous reply
    Srinivas Tamada said...
    Paypal sandbox updated new sample biz id not redirecting properly.

    now my question is have any other alternative method it must work with my Id its my university project help me please

    ReplyDelete
  110. neeeeeeeeeeed help

    i tried this code every thing is ok but not get return value on success.php file.
    i make new account on developer.paypal.com i must need retune value its my university project tell me alternative solution please i am waiting.

    ReplyDelete
  111. Can we refund any transaction by using same kind of form or is that compulsory to use API for refund. Please suggest.

    ReplyDelete
  112. sriniv_1293527277_biz@inbox.com id not working

    paypal page give this error
    This recipient does not accept payments denominated in USA. Please contact the seller and ask him to update his payment receiving preferences to accept this currency


    ReplyDelete
  113. I make buyer and seller account on sandbox if m trying u r demo then its working but its not working if i m trying it on my domian or local
    giving this error

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/cyberdev/appoint.cybertronindia.com/testingpaypal/success.php on line 15
    Payment Failed

    ReplyDelete
  114. hello sir ,

    as i am using paypal , i already implied it , but after return paypal retusn a URL like this ---


    "http://localhost:8082/btmcode/membership/payment_success?tx=6A569037D29032236&st=Completed&amt=30%2e00&cc=USD&cm=&item_number=&sig=AZMo27QReSlttWDtIVlmbpHDn33QCGaMTXuWNKp12dLpoJDrm%252bENyNnNJxv2H%252bYWdl%252bnp85BIwiTJK1Cl0H0Oq9fY0%252fSEwJCXz6FuBL12zZVatKj5%252bK%252bT2KjKHgbmJfklOh29q7nGxHYsRMoDiDyiam8rWbbthnE8dmawJxbHTM%253d"

    this i am using for subscribing , i need your help to get the response code.

    so i can make a condition after return its succeded or fail.

    ReplyDelete
  115. Hi Sri

    I am Aditi Champaneria
    So many follower and now one more !!!

    ReplyDelete
  116. hi for redirection problem every one follow
    sakkona comments...

    I followed his steps thank you so much sakkona

    1. log in with Business mail account in https://www.sandbox.paypal.com/
    2. click on profile link
    3. under hosted payment settings > click Website payment preferences
    in that, configure some points:
    set Auto Return to On and type return URL address (e.g. http://localhost/paypal/success.php)
    set Payment Data Transfer to On

    thats all once again thanks u so much sakkona..

    ReplyDelete
  117. http://localhost/mywork/paypal/paypal/success.php..This is my successful page but after payment am getting transaction id ..but in url no arguments is passing

    ReplyDelete
  118. Anonymous said... please tell me me too getting same error no arguments passing through url showing payment error. what should i do for this

    ReplyDelete
  119. Thanks Srinivas

    This is really helpful

    Chaminda

    ReplyDelete
  120. nice tutorial

    ReplyDelete
  121. Is it true that the redirection can only work if you use business-pro account(paypal payments pro)? Because I already tried it, and it really works. Thanks.

    ReplyDelete
  122. Very Nice tutorial, bt i can't able to mak payment, the following error is showing....pls help............the error is:-
    "We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller. Please contact the seller to resolve the problem. If this payment is for an eBay listing, you can contact the seller via the "Ask Seller a Question" link on the listing page. When you have the correct email address, payment can be made at www.paypal.com.
    Return to merchant"

    ReplyDelete
  123. Hi Srini.....am new vth paypal,n doing this first time, eventhough im feeling itz very simple bcz of ur tutorial, bt i cn't abl to make payment, the following error is showing....
    "We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller. Please contact the seller to resolve the problem. If this payment is for an eBay listing, you can contact the seller via the "Ask Seller a Question" link on the listing page. When you have the correct email address, payment can be made at www.paypal.com."
    PLZZZZZZZZZZZZZ Help

    ReplyDelete
  124. i got errors in success.php page.

    there have no argument passed to the return url in payapal after click to return.....

    ReplyDelete
  125. Hello Friends,

    I am using live environment and I am not getting return parameter on success.php file.

    any can help me.

    Thanks
    Brij Kishor

    ReplyDelete
  126. Hi Srini... This is nice one tuttorial but i am facing a problem after payment its not redirect back to my PHP success page,even i have set return radio box on and specify the sucess path there

    ReplyDelete
  127. Boss how can i send multiple items through your code ?

    ReplyDelete
  128. i got errors in success.php page.

    there have no argument passed to the return url in payapal after click to return.....plz help

    ReplyDelete
  129. i want the current transaction date and time in return

    ReplyDelete
  130. This script working perfect but how can i made split payment to two or more accounts

    ReplyDelete
  131. Please run below URL and you will get success page.

    http://demos.9lessons.info/paypal/success.php?tx=9T051072DR109605J&st=Completed&amt=30%2e00&cc=USD&cm=&item_number=2

    ReplyDelete
  132. Payment is getting success, after payment it is not returning. am seeking for a solution nearly 3 days, some one help me soon.......

    ReplyDelete
  133. Hii,
    Return url, after cancel the recurring paypal payment through manually...

    ReplyDelete
  134. i am not getting the txt and amt while returning from paypal please help me to get transaction, id order no and amt

    ReplyDelete
  135. HI
    Plz provide Multiple item paypal payment gateway in php

    ReplyDelete
  136. hi
    Srinivas Sir
    how can i send multiple items through your code ?

    ReplyDelete
  137. hey, after downloading this tuts, i have redirection array empty, and paypal is now using REST API, can you please make this tutorial update on this REST API?

    ReplyDelete
  138. Last 3 days i am trying to integrated paypal integration in my project. Lot of confusion. Today(23-11-2013) only i see your page. Its very simple and very very useful to me. Thanks thalaiva.

    ReplyDelete
  139. when returning url after successful payment the payment status displays as pending in paypal sandbox.How to solve it?

    ReplyDelete
  140. hi,

    can u explain about how to implement refund in paypal sandbox.

    ReplyDelete
  141. Hi Tamada,
    How To Verify PayPal Account with VCC

    ReplyDelete
  142. Hi my payment part is working fine but not able to direct to the success page and the sales table is also not updating. Plz help.

    ReplyDelete
  143. i not able to direct to the success page and the sales table is also not updating. Plz help.

    ReplyDelete
  144. you are not redirecting because paypal has changed the way id can be fetched in new accounts so enter your return url in your account settings.

    ReplyDelete
  145. Nice Post paypal payment system...
    but i can recived payment in my paypal account....how can i create...plz reply...

    ReplyDelete
  146. then, this need a server online?

    ReplyDelete
  147. I haven't get this value from server
    please help me..

    $item_no = $_POST['item_number'];
    $item_transaction = $_GET['tx'];
    $item_price = $_GET['amt'];
    $item_currency = $_GET['cc'];

    ReplyDelete
  148. Trascation id is not get from redirect time from paypal ......
    please help ...

    ReplyDelete
  149. I have one problem.. I have two websites and one business account.. I saw some solution like creating each mail to each websites. But i don't know how to execute it in rea. Please help me anyone.....
    Thanks in advance.

    ReplyDelete
  150. Url not return on success.php please help me.....

    ReplyDelete
  151. my problem is the same:
    Url not return on success.php.....Yeah pls help!

    ReplyDelete
  152. hi, thanks for providing this tutorial. I completed almost. i was able to retrieve transaction id and amount. but i need some more info regarding transaction like first name, last name,email etc.. could u plz help me out to solve this problem...

    Thanks in advance..

    ReplyDelete
  153. Hello!
    Thanks for your tutorial !
    Unfortunately I don't know a lot about php .Have someone has this code , or just the paypal buying operation in JSP ? thanks in advance :)

    ReplyDelete
  154. nice tutorial...helpful

    ReplyDelete
  155. I haven't get this value

    $item_no = $_GET['item_number'];
    $item_transaction = $_GET['tx']; // Paypal transaction ID
    $item_price = $_GET['amt']; // Paypal received amount
    $item_currency = $_GET['cc']; // Paypal received currency type

    My transaction is done. but i got empty Array. please help

    ReplyDelete
  156. I haven't get this value
    $item_no = $_GET['item_number'];
    $item_transaction = $_GET['tx']; // Paypal transaction ID
    $item_price = $_GET['amt']; // Paypal received amount
    $item_currency = $_GET['cc']; // Paypal received currency type

    ReplyDelete
  157. Hi All,

    Please let me know the fix for this issue.

    Issue : Paypal is not returning tx,st,amt,cc,item_number,

    In other words it route correctly to success.php without returning above mentioned parameters

    ReplyDelete
  158. i am having the same problem as SK, when returning back to my success.php it wont pass the get variables from your script so it failes everytime

    ReplyDelete
  159. how to change indian currency code value

    ReplyDelete
  160. Have you ever heard the term "Transaction"??? It's funny that you have put a "select" near an "insert into" assuming that nothing can change between both execution

    ReplyDelete
  161. What about the user that will edit the source code of the page and change value of the amout to 0.01 USD?

    ReplyDelete
  162. Hi Srinivas, great work.. but when am trying.. return url is empty like sucess.php instead of success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1 how can i solve this problem ?

    ReplyDelete
  163. please tell me how to resolve issue is that please make sure all fields is set complete during paypal login through android app integration

    ReplyDelete
  164. Hi ,

    No need to consider about IPN ?

    ReplyDelete
  165. i m new in php ...
    hidden input field values we can edit using firebug on form while submitting to paypal, how to resolve this problem .....plz rly .....

    ReplyDelete
  166. What if user change the value of hidden field named 'amount' using developer tool.
    And what will be the solution for that.

    ReplyDelete
  167. Hi,
    please tell me how to can Indian Paypal user add Donate button in blog?
    What is Indian laws, rules & conditions to add Donate button in blog?
    Please Help

    ReplyDelete
  168. I got an error
    {
    We can not process this transaction because there is a problem with the email address provided by PayPal PayPal trade. Contact trade to solve the problem. If this payment goes to an eBay listing, you may contact the seller using the link "Ask seller a question" page of the advertisement. Once you have the correct email address, payment can be made at www.paypal.com.
    }

    Plz hep what does it means

    ReplyDelete
  169. I ON Auto Return for Website Payments and ON Payment Data Transfer and also set Return URL but it return url is empty like sucess.php instead of success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1
    help please.Thanks

    ReplyDelete
  170. Hi can any one help us by giving same code for "Refund" process?

    ReplyDelete
  171. Not able to create a Test account, it asks to login using paypal account and I don't have one currently. What can I do for this, neither there is any Menu named as 'Test Account'

    ReplyDelete
  172. How to do if I want to change the status in my database without redirecting back to my website. Which means I want everything on Paypal.

    ReplyDelete
  173. Hi All,

    Please let me know the fix for this issue.

    Issue : Paypal is not returning tx,st,amt,cc,item_number,

    In other words it route correctly to success.php without returning above mentioned parameters

    ReplyDelete
  174. I Am Unable To Get Back tx,st,amt,cc,item_number,

    ReplyDelete

Make in India