JonnySnip3r Posted January 4, 2011 Share Posted January 4, 2011 Hey guys i was wondering if someone could help or guide me. I have been messing around with php for quite some months now to the stage where i can code pretty much what i need to. but recently i started using paypals IPN and during testing i realised some problems arise for example when testing and people buying things say the payment failed due to a line not executing in your script for what ever reason, the person has lost their money yet you have gained it and they are lost. Take this code below for example: public function insertIntoDatabase($firstName,$lastName,$emailAddress,$merchant,$code,$database,$gameNumber) { $year = date("Y"); // Check what database we need to submit too:: $sql = "INSERT INTO playerGame (playerFirstName, playerLastName, playerEmailAddress, playerAccountType, playerCode, playerGameDate, playerGameNumber) VALUES (?,?,?,?,?,?,?)"; $stmt = $this->conn->prepare($sql); $stmt->bind_param('ssssssi',$firstName,$lastName,$emailAddress,$merchant,$code,$year,$gameNumber); $stmt->execute(); $stmt->close(); return true; } this is called on success the paypal IPN script. But what happens if this fails to execute? I suppose i could wrap it in a variable on the other side and test it if($task) { echo "code executed"; } but what happens if this fails ? of am i just being paranoid ? hope someone can help dont want to be ripping people off =] Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/223364-good-php-error-handling-involving-paypal/ Share on other sites More sharing options...
denno020 Posted January 4, 2011 Share Posted January 4, 2011 I have just had some fun with PayPal's IPN myself. You use the IPN script to check if the payment is a success (if it is complete). So you use an if statement similar to: if($payment_status == "Completed"){//do the database insertion stuff here} You add further else if for payment status of failed, and all the other possible ones. From there, I can't see how a line of code wouldn't execute. You just need to make sure you test your script thoroughly using the PayPal IPN simulator in the PayPal developer section. If that is always right, then there is no reason why it would fail in real world applications... Denno Quote Link to comment https://forums.phpfreaks.com/topic/223364-good-php-error-handling-involving-paypal/#findComment-1154657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.