Log in

View Full Version : paypal api php return url help



ianhaney
12-31-2015, 12:01 PM
Hi

I have created a site that when users are logged in, they click a link which takes them to PayPal to pay and then returned to a form page to fill out a job advert, it all works perfect apart from one little issue I have

after they submitted the job advert form and is added to the db, they close the page after logging out and then open that page again, they can add another job advert again without paying so was seeing if there is any coding that checks if they have not paid and it redirects them to a error page if they not paid and try accessing the job advert form page

Hope that makes sense

This is the script I am using that works apart from the return url issue where they can access the return url again without paying so need a way of checking if the user has paid or not

http://www.sanwebe.com/2012/07/paypal-expresscheckout-with-php

Thank you in advance

Ian

ianhaney
12-31-2015, 01:46 PM
Think I figured a way round it but unsure how to code it

in BuyerTable I have added a paid and complete column so when the payment is made via PayPal the paid column gets updated to a 1 for Yes, I have set it to default of 0 for No and then when they submit the job advert the complete column gets updated to a 1, again I have set that to a default of 0

it's the coding where I am getting stuck, I am completing the payment and takes me to the return url but the paid column is not being updated to a 1

below is the coding I have from my process.php file that does the PayPal API that adds the transaction to the db



$insert_row = $mysqli->query("INSERT INTO BuyerTable
(BuyerName,BuyerEmail,TransactionID,ItemName,ItemNumber,ItemAmount)
VALUES ('$buyerName','$buyerEmail','$TransactionID','$ItemName','$ItemNumber', '$ItemTotalPrice')");

$update_row = $mysqli->query("UPDATE BuyerTable SET paid = 'Y' WHERE TransactionID = '$TransactionID'");

ianhaney
12-31-2015, 02:10 PM
Sorry made a slight adjustment in the UPDATE query to the following

UPDATE BuyerTable SET paid = '1' WHERE TransactionID = '$TransactionID'

but it is not updating the paid column