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.
Download Script Live Demo
Sample database design for Payment system. Contains there table users, products and sales.
Users
CREATE TABLE `users` (
`uid` int(11) AUTO_INCREMENT PRIMARY KEY,
`username` varchar(255) UNIQUE KEY,
`password` varchar(255),
`email` varchar(255) UNIQUE KEY,
)
`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),
)
(
`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)
)
(
`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
Step 3
Here I have created two accounts Buyer (personal) and Seller (merchant/business) 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']; ?>'>
<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>
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']; ?>'>
<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";
}
?>
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>";
?>
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';
to
$paypal_url='https://www.paypal.com/cgi-bin/webscr';
nice, i have some project that needed to integrate with PP, and you make this tuts :)
ReplyDeletegreat :)
nice !! :-) ... you are a genius ... you always make complicated things easier ...
ReplyDeleteHow 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.
ReplyDeleteWell done. Thank you guy.
ReplyDeleteHi srini, nice tute as usual..:) is creating test account on paypal free or payable?
ReplyDeleteSrinivas, I'm curious about your database graph. What do you use when designing databases?
ReplyDeleteHey Great tutorial, Srinivas, thank you from Perú.
ReplyDeleteOmg.... Asians rock!
ReplyDeleteGreat post Srinivas... we like these kind of innovative posts. Thanks a lot.
ReplyDeleteSQL Injection, no verification that a call to success.php actually came from PayPal (and is valid)...words fail me.
ReplyDeletethis tutorial ROCKS! thank you very much dude :D
ReplyDelete@Dan Mysql Workbench for database ER diagrams.
ReplyDeletewaw..thanks for sharing Srinivas..:)
ReplyDeleteYou 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:
ReplyDelete<--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.
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
ReplyDeletehi,
ReplyDeletei 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...
Hey Srini,
ReplyDeletei got the same error like ashish...
Nice post. I solved my problem very well.
ReplyDeleteThanks
Modified 'success.php' file code. Re-checking the product price and currency details
ReplyDeletehi srini, my question is .. in step 1 we need to register for the sandbox account.. is it paid account ??
ReplyDelete@Sreevathsa
ReplyDeleteIt's free just test account
hey Sri its not TEXT ACCOUNT its TEST Brother I think a little typo mistake is there.. :)
ReplyDeletei 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?
ReplyDeleteFor me its not safe, also the return url dont have transaction id for me.
ReplyDeleteVery Handy tuts :)
ReplyDeleteitem_number. Paypal data success.php?tx=270233304D340491B&st=Completed&amt=22.00&cc=USD&cm=&item_number=1
ReplyDeletewhat $_GET[???], is Quantity???
its post is nice but why are you using IPN for update database.
ReplyDeletePlease advice how to use this tutorail to protect digital file. if success able to download file if not protected digital file.
ReplyDeleteHi. 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
ReplyDeleteWhats the problem here? Or is it only a sandbox problem?
Thanks.
nice info..
ReplyDeleteDear Srinivas Tamada,
ReplyDeletei 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.
Same with Nguyen Hai Dang
ReplyDeleteSanbox new accounts success redirection problem.
ReplyDeleteIt 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.
ReplyDeleteI 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?
@Nguyen Hai dang
ReplyDeleteI 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.
Hi,
ReplyDeleteCan 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.........
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@dskanth
ReplyDeletePaypal Sanbox creating some problem with new registration accounts. Success page not redirecting well try to use my test merchant email.
thank you from LA. great tutorial!
ReplyDeletethanks from LA!
ReplyDeleteAwsome tutorial it wrks in my web, buti need to pay several products but it only sends one, how can i do it?
ReplyDeleteMan 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.
ReplyDeletehi dear Srinivas Tamada
ReplyDeleteits 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
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
ReplyDeletewill you please tell me how it will done??
ReplyDeletei 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
Maybe must add feature to download product and expired download link..
ReplyDeleteThanks
Hi,
ReplyDeleteNice 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.
Hi Srinivas,
ReplyDeletei send a feed back to you regarding this tutorial . It was my mistake. It working fine with your $paypal_id ='[email protected]' but when i use my pay pal id [email protected]
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 [email protected]
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.
ReplyDeleteWarning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\paypal\success.php on line 15
ReplyDeletePayment Failed
hi, Srinivas thanks for your tutorial.
ReplyDeleteit'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.
really good to see this blog...
ReplyDeleteI need one help from how can i create test account for money booker payment gateway..
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....
ReplyDeleteHi
ReplyDeleteIn 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?
@ Srinivas,
ReplyDeleteI 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.
Hi Srinivas,
ReplyDeleteIt works fine with your $paypal_id ='[email protected]' 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.
Hi Seyha
ReplyDeletePaypal sandbox updated new sample biz id not redirecting properly.
Hi, I used it but it live for Paypal Send box but it only show
ReplyDeleteThanks for your order page of Paypal, not redirect to success.php and therefore does not insert record into sales table.
Hi, your code helped me to start my code with.
ReplyDeleteFacing 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??
OMG, you save my time, thanks. love this tutorial.
ReplyDeleteHi Srinivas Tamada,
ReplyDeleteI '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.
Hi!
ReplyDeleteso 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/
Hi Srinivas,
ReplyDeletewhen 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?
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"
ReplyDeleteit just goes to "success.php" why is that?
@Gurav, this is something I also want to know
ReplyDeleteIs it possible to pay the amount to two account at a single time?
ReplyDeleteI 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).
need to explain more clearly dear
ReplyDeleteI am getting the following error
ReplyDeleteThis recipient is currently unable to receive money
What should i do
Hay First of all thanks dude...
ReplyDeleteI try your demo code and its work properly but in final step i can't redirect on sucess.php pls replay fast...
Thanks again..
Hi Srinivas Tamada,thank u for update
ReplyDeleteI '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.
nice work.......
ReplyDeleteIs 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.
ReplyDeleteI 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?
ReplyDeleteAwesome!!!!! I never see on the web like this..!
ReplyDeleteIt's excellent Srinivas.
ReplyDelete@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
Thank You Man It Is Grate...
ReplyDeleteReally, it's amazing tutorial for us...
ReplyDeleteThank You....very much G...
Awesome bro.. helped me like HELL!!
ReplyDeleteGreat tutorial.. Thanks a bunch!! Didn't know Paypal transactions were so easy. :D
ReplyDeleteBut 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
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:
ReplyDeleteCREATE 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...
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..
ReplyDeleteAddPage();
$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();
?>
ReplyDeleteHow 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
any Help is apperciatable
ReplyDeleteWhy 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
please tell me how to turn on Auto Return for testing account?i have created 2 account as business and personal as preconfigured accounts.
ReplyDeleteanother error on success php
ReplyDeleteif($item_price==$price && item_currency==$currency)
item_currency is missing a $
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\paypal(2.0)\products.php on line 40
ReplyDeletegetting this error pls help
All went perfectly..just one error while returning from paypal page.Got following error:
ReplyDeleteThe requested URL /paypal/success.php was not found on this server.
Thanx for d tutorial
Hi
ReplyDeleteWhen 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.
This code can't user for production site.Use Paypal IPN to receive payment notification.
ReplyDeletehttp://code.google.com/p/paypal-ipn-class-php/
Man you saved my life many times already! :D
ReplyDeletei am using the same code as mentioned but i my success url transactiion id is not coming .. what to do ?
ReplyDeleteplease help
I am not getting the transction id after successful payment..
ReplyDeletewhat to do ?
please help
Hi shirni..
ReplyDeleteI 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?
not working for me. redirect url not passing data.. Please help me
ReplyDeletei had the same issue with paypal not auto returning or getting data about transaction.
ReplyDeleteif 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.
forgot to say thanks @Srinivas Tamada :D
ReplyDeletecan't get the transaction number..when back to sucess.php please help...
ReplyDeleteHow to pass other custom values to paypal... because i want to save more than 5 values in success.php from client
ReplyDeletethanks 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.
ReplyDeleteif any would help me i would be greatful
hi !
ReplyDeleteI 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.
i found this very informative thanks for sharing..
ReplyDeletehi i liked ur post a lot and was helpful too.can u provide same example in jsp?
ReplyDeletethis was very helpful thanks but can u give same example in jsp?
ReplyDeletehi 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.
ReplyDeleteAwesome tutorial - ! good joob
ReplyDeleteHi 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..
ReplyDeletewe are going to use it in our classified sites...
ReplyDeleteA great way for transaction
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?
ReplyDeletehow to get responce automaticly from paypal ? plese explain
ReplyDeletecan you please expalin how to get responce automaticly on sucess.php or how to show all payment detail on own website page after payment ?
ReplyDeleteI get this error:
ReplyDeleteParse 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?
I'm impressed with the way you have condensed pages and pages of PayPal bumff into this concise and easily understood article! Well done!
ReplyDeleteP.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...
nice code, this really help me
ReplyDeleteneed help
ReplyDeleteits work fine with your $paypal_id ='[email protected]' 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
neeeeeeeeeeed help
ReplyDeletei 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.
Can we refund any transaction by using same kind of form or is that compulsory to use API for refund. Please suggest.
ReplyDelete[email protected] id not working
ReplyDeletepaypal 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
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
ReplyDeletegiving 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
hello sir ,
ReplyDeleteas 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.
Hi Sri
ReplyDeleteI am Aditi Champaneria
So many follower and now one more !!!
hi for redirection problem every one follow
ReplyDeletesakkona 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..
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
ReplyDeleteAnonymous said... please tell me me too getting same error no arguments passing through url showing payment error. what should i do for this
ReplyDeleteThanks Srinivas
ReplyDeleteThis is really helpful
Chaminda
nice tutorial
ReplyDeleteIs 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.
ReplyDeleteVery Nice tutorial, bt i can't able to mak payment, the following error is showing....pls help............the error is:-
ReplyDelete"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"
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....
ReplyDelete"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
i got errors in success.php page.
ReplyDeletethere have no argument passed to the return url in payapal after click to return.....
Hello Friends,
ReplyDeleteI am using live environment and I am not getting return parameter on success.php file.
any can help me.
Thanks
Brij Kishor
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
ReplyDeleteBoss how can i send multiple items through your code ?
ReplyDeletei got errors in success.php page.
ReplyDeletethere have no argument passed to the return url in payapal after click to return.....plz help
i want the current transaction date and time in return
ReplyDeleteThis script working perfect but how can i made split payment to two or more accounts
ReplyDeletePlease run below URL and you will get success page.
ReplyDeletehttp://demos.9lessons.info/paypal/success.php?tx=9T051072DR109605J&st=Completed&amt=30%2e00&cc=USD&cm=&item_number=2
Payment is getting success, after payment it is not returning. am seeking for a solution nearly 3 days, some one help me soon.......
ReplyDeleteHii,
ReplyDeleteReturn url, after cancel the recurring paypal payment through manually...
i am not getting the txt and amt while returning from paypal please help me to get transaction, id order no and amt
ReplyDeleteHI
ReplyDeletePlz provide Multiple item paypal payment gateway in php
hi
ReplyDeleteSrinivas Sir
how can i send multiple items through your code ?
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?
ReplyDeleteLast 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.
ReplyDeletewhen returning url after successful payment the payment status displays as pending in paypal sandbox.How to solve it?
ReplyDeletehi,
ReplyDeletecan u explain about how to implement refund in paypal sandbox.
Hi Tamada,
ReplyDeleteHow To Verify PayPal Account with VCC
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.
ReplyDeletei not able to direct to the success page and the sales table is also not updating. Plz help.
ReplyDeleteyou 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.
ReplyDeleteNice Post paypal payment system...
ReplyDeletebut i can recived payment in my paypal account....how can i create...plz reply...
then, this need a server online?
ReplyDeleteI haven't get this value from server
ReplyDeleteplease help me..
$item_no = $_POST['item_number'];
$item_transaction = $_GET['tx'];
$item_price = $_GET['amt'];
$item_currency = $_GET['cc'];
Trascation id is not get from redirect time from paypal ......
ReplyDeleteplease help ...
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.....
ReplyDeleteThanks in advance.
Url not return on success.php please help me.....
ReplyDeletemy problem is the same:
ReplyDeleteUrl not return on success.php.....Yeah pls help!
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...
ReplyDeleteThanks in advance..
Hello!
ReplyDeleteThanks 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 :)
nice tutorial...helpful
ReplyDeleteI haven't get this value
ReplyDelete$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
I haven't get this value
ReplyDelete$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
Hi All,
ReplyDeletePlease 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
thankyou
ReplyDeleteThanks ....
ReplyDeletei 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
ReplyDeletehow to change indian currency code value
ReplyDeleteHave 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
ReplyDeleteWhat about the user that will edit the source code of the page and change value of the amout to 0.01 USD?
ReplyDeleteHi 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 ?
ReplyDeleteplease tell me how to resolve issue is that please make sure all fields is set complete during paypal login through android app integration
ReplyDeleteHi ,
ReplyDeleteNo need to consider about IPN ?
i m new in php ...
ReplyDeletehidden input field values we can edit using firebug on form while submitting to paypal, how to resolve this problem .....plz rly .....
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteplease 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
I got an error
ReplyDelete{
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
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
ReplyDeletehelp please.Thanks
Hi can any one help us by giving same code for "Refund" process?
ReplyDeleteNot 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'
ReplyDeleteHow 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.
ReplyDeleteHi All,
ReplyDeletePlease 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
I Am Unable To Get Back tx,st,amt,cc,item_number,
ReplyDeleteThanks 9 lessons
ReplyDeleteit rocked
please make a tutorial on paypal ipn listner
ReplyDeletePlease provide tutorial on Paypal pro integration with php!
ReplyDeletehow can i show this data on jsp
ReplyDelete