100 thoughts on “PayPal Payments Integration Tutorial Using PHP & IPN & PHPMailer

  • July 1, 2018 at 2:29 pm
    Permalink

    can i add a button with pay pal freelancer account

    Reply
  • July 6, 2018 at 6:12 am
    Permalink

    Will my website need PCI-DSS compliance even if I use this method?

    Reply
  • July 11, 2018 at 12:17 pm
    Permalink

    Just what I was looking for. thanks!

    Reply
  • July 11, 2018 at 5:36 pm
    Permalink

    Just foundyourchanneland after 2 tutorial I just subscribedn hit notifications.Great tutorials Sir.
    I have a request though about paypal payments. A tutorial on Paypal Implicit payment. No need to add IPN to it coz i've understood i there. Thanks

    Reply
  • July 15, 2018 at 1:27 am
    Permalink

    Hi Senaid. Do you have any tutorials or codes for IPN in classic ASP. I have tried for days and no joy what so ever. Trying with the IPN listerner simulation works but can't get it to work when I submit my form. Thanks.

    Reply
  • July 16, 2018 at 7:58 am
    Permalink

    Great tutorial keep up the good work! Could you create one about recurring payments and subscription status check?

    Reply
  • July 17, 2018 at 12:13 am
    Permalink

    Amazing Code Passive Income

    Reply
  • July 19, 2018 at 12:20 am
    Permalink

    It always returning INVALID in test.txt can u please help me?

    Reply
  • July 27, 2018 at 1:05 am
    Permalink

    40:43

    Reply
  • July 27, 2018 at 3:51 am
    Permalink

    For the last couple months it looks as if everyone has gotten "INVALID", regardless that the sandbox saying: "IPN was sent and the handshake was verified". This issue is all over different forums. Is there another way to get this done?

    Reply
  • July 29, 2018 at 6:38 am
    Permalink

    PAYPAL IPN SIMULATOR ISSUE

    Hi! I'm following this tutorial and when I get to the testing part I always get an 'INVALID' response from the PayPal IPN SIMULATOR. I did some research and it seems that I'm not the only one with this issue. Some even say that the simulator always returns INVALID but the video shows a VALID response.

    Here is what I tried so far:

    -I checked the sandbox URL and it's ok (https://ipnpb.sandbox.paypal.com/cgi-bin/webscr)
    -I tried this IPN code sample that solves the DATE problem https://github.com/paypal/ipn-code-samples (it seems to be a problem with date encoding, when you send the raw URL a + sign is missing, here is an alleged solution about it https://www.sitepoint.com/quick-tip-solution-to-paypal-ipn-always-returning-invalid/)
    -I changed my paypal accounts encoding acording to this suggestion: https://stackoverflow.com/questions/1485832/paypal-sandbox-ipn-return-invalid

    I still get and INVALID response. If anyone can give me a hint it would be really appreciated!

    Reply
  • August 3, 2018 at 9:37 pm
    Permalink

    Hello! I'm always getting "INVALID" ! Can you please help me? Thanks you! <3

    Reply
  • August 25, 2018 at 3:37 am
    Permalink

    Hi, IPN Simulator aways returns Internal Server Error, do you know what?

    Reply
  • August 26, 2018 at 5:17 am
    Permalink

    Hello Senaid Please i tried your code but parameters are not sent to the notify_url which is listener.php can you help please 🙁

    Reply
  • September 8, 2018 at 11:55 am
    Permalink

    but in this cas not good beacause, suppose we have 10000 product and i want to buy it, so we have create 10000 ipn and "BUY NOW " button so, it is not good, bad

    Reply
  • September 11, 2018 at 6:23 am
    Permalink

    i im having a problem that instead of the information return in POST its returning GET
    i dont know how to change it

    Reply
  • September 14, 2018 at 3:12 am
    Permalink

    I've been working on a subscription-based website for more than a year and was very intimidated by this portion of the project… Still working on getting this thing up and running but your video has been a big help! Thank you!

    Reply
  • September 14, 2018 at 7:53 pm
    Permalink

    What is curl??

    Reply
  • September 15, 2018 at 8:15 pm
    Permalink

    dude more videos plz

    Reply
  • September 29, 2018 at 9:08 pm
    Permalink

    bro how if its in the cart and i want to save the ordered lists into a sql db after the payment

    Reply
  • October 1, 2018 at 8:34 am
    Permalink

    i got an error in paypal ipn stimulator "IPN was not sent, and the handshake was not verified. Review your information." what should i do?

    Reply
  • October 4, 2018 at 12:59 pm
    Permalink

    Dont work :c

    Reply
  • October 5, 2018 at 8:46 am
    Permalink

    sir, please make a video on how to send money form our account to users paypal account…
    sir please give a response on these topic…please sir plesase…. i can't understand the way which paypal developer says to use…
    hope sir you create a video on it….

    Reply
  • October 11, 2018 at 11:31 pm
    Permalink

    i dont get this… normally on paypal their is everything you need… i dont understand the code he implements… on paypal u can send an amount to paypal… if user pays paypal redirects to a thank you page on your website… if not paypal sends them back or you can redirect them back to home… this all is done by paypal…

    Reply
  • October 12, 2018 at 12:01 am
    Permalink

    2.5% + 0.35 cents… have fun xD so 100$ -> 2.85$ goes to paypal… thats too much… i mean they have nearly no expenses… no large databases like facebook or google… nothing and they still earn so much…

    Reply
  • October 14, 2018 at 11:03 pm
    Permalink

    Nice video. I have implemented paypal payment gateway learned from here.

    Reply
  • October 16, 2018 at 11:11 pm
    Permalink

    I can't make it work. Maybe because my website is in .html not .php. And even when i transfered everything to .php, it didn't work. I'm just not good at .php

    Reply
  • October 18, 2018 at 8:10 pm
    Permalink

    Is there any way to configure the PayPal button? I want to create cart script and the price will change.

    Reply
  • October 21, 2018 at 6:30 am
    Permalink

    IPN was not sent, and the handshake was not verified. Review your information.
    Any solution?

    Reply
  • October 21, 2018 at 1:10 pm
    Permalink

    24:32 My listener always says "This page doesn't work"….

    Reply
  • October 22, 2018 at 12:38 am
    Permalink

    I am getting "IPN was not sent, and the handshake was not verified. Review your information" – i have a test vps – LAMP installed.. What is wrong? There is no explicit point out of issue. Also, i use your codes. I put all the codes in root dir of the vps. Please help.

    Reply
  • October 24, 2018 at 4:17 am
    Permalink

    Is it mandatory to create a button? how could I manage code for dynamic price?

    Reply
  • October 24, 2018 at 6:01 am
    Permalink

    Everything works perfectly but we want it to be in sandbox mode and for some reason it is using live payments. Any tips?

    Reply
  • October 30, 2018 at 9:08 am
    Permalink

    ¡Awesome!, you won a new suscriber, i have never ever comment a video, this is my first comment 🙂

    Reply
  • October 31, 2018 at 11:53 pm
    Permalink

    THIS IS EXACTLY WHAT I WAS LOOKING FOR!!! YOU HAVE JUST EARNED A NEW SUBSCRIBER, GOD BLESS YOU!

    Reply
  • November 6, 2018 at 10:33 pm
    Permalink

    thx for help me ur the best

    Reply
  • November 15, 2018 at 3:44 pm
    Permalink

    IPN was not sent, and the handshake was not verified. Review your information.
    sir i have an error kindly help me

    Reply
  • November 19, 2018 at 8:00 pm
    Permalink

    Best tuitorial on youtube, consider being a teacher alot of programmes can learn easily from you.

    Reply
  • November 23, 2018 at 10:20 am
    Permalink

    Do you have tutorial on multiple items at checkout with paypal?

    Reply
  • November 23, 2018 at 5:34 pm
    Permalink

    BEWARE ON DOWNLOAD: VUL.Webshell -> ( Analysis from Bkav )

    Reply
  • November 27, 2018 at 3:10 pm
    Permalink

    i have a very big question. i got an ssl certificate i suposse that it prevents the writting of test.txt file, but does ssl affects the phpmailer somehow? do i need to add something to the code or change it? im sending it from port 465 but still nothing. this is my code

    <?php

    use PHPMailerPHPMailerPHPMailer;

    require "PHPMailer/PHPMailer.php";

    require "PHPMailer/Exception.php";

    if ($_SERVER['REQUEST_METHOD'] != 'POST') {

    header('Location: diplomadoventas.php');

    exit();

    }

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    curl_setopt($ch, CURLOPT_POST, 1);

    curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));

    $response = curl_exec($ch);

    curl_close($ch);

    $dir = 'myDir';

    // create new directory with 744 permissions if it does not exist yet

    // owner will be the user/group the PHP script is run under

    if ( !file_exists($dir) ) {

    mkdir ($dir, 0744);

    }

    file_put_contents ($dir.'/test.txt', $response);

    if($response == "VERIFIED" && $_POST['receiver_email'] == "*********"){

    $cEmail = $_POST['payer_email'];

    $name = $_POST['first_name'];

    $price = $_POST['mc_gross'];

    $currency = $_POST['mc_currency'];

    $item = $_POST['item_number'];

    $paymentStatus = $_POST['payment_status'];

    if ($item == "************" && $currency == "USD" $$ $paymentStatus == "Completed" && $price == 0.097) {

    $mail = new PHPMailer();

    $mail->setFrom("************", "Sales");

    $mail->addAdress($cEmail, $name);

    $mail->isHTML(true);

    $mail->Subject = "sales";

    $mail->Body = "Hola, <br><br>

    thanks";

    $mail->Port= 465;

    $mail->send();

    }

    }

    ?>

    i know that this isn't stack overflow but HALP me pls.
    it isn´t creating the new folder with writting permissions.
    im getting handshake veryfied by paypal.

    Reply
  • November 30, 2018 at 12:05 am
    Permalink

    Hi, how could i create a paypal checkout page that only shows the credit cards option as primary choice with the PayPal API?

    Reply
  • December 3, 2018 at 5:15 pm
    Permalink

    is the word verified case sensitive at line 17? I also thought that your foreach loop should have a {} but it doesn't…

    Reply
  • December 3, 2018 at 7:02 pm
    Permalink

    Hello! I tried to add a redirect in my listener.php but it is not redirecting me to another page. Basically, once the user has made a purchased, I would like to send the user to another page where an email will be sent…

    Reply
  • December 4, 2018 at 9:21 pm
    Permalink

    I recieve this : "IPN was not sent, and the handshake was not verified. Please review your information." What s the prb?

    Reply
  • December 8, 2018 at 1:21 pm
    Permalink

    Do you want to become a web developer from scratch??? Check this: http://bit.ly/devAccelerator

    Reply
  • December 8, 2018 at 2:17 pm
    Permalink

    Thank you for such a great tutorial. Senaid you are great man.

    Reply
  • December 17, 2018 at 1:51 pm
    Permalink

    Hey guys! I would appreciate if someone could reply to my question here but I tried to use the header or meta redirect tag and both can't seem to redirect the user at all. I don't know why but even using a basic command like echo "<meta http-equiv='refresh' content='0;url=mail_level1monthly_paid.php'>"; does not work… I can only get it to work with the include_once attribute.. Just like to know if someone has got it working…

    Reply
  • December 19, 2018 at 11:06 am
    Permalink

    Hi Bego, I really enjoyed your tutorial. Very clear and you go through each step, which is great for me. I noticed that you put condition if $paymentStatus == "Confirmed". Isn't the value you are looking for to be "Completed"? It is how it comes in the text.txt output. Thank you.

    Reply
  • December 29, 2018 at 8:24 pm
    Permalink

    https://developer.paypal.com/developer/ipnsimulator
    >?>>
    IPN was not sent, and the handshake was not verified. Review your information.

    Reply
  • January 8, 2019 at 11:07 am
    Permalink

    SIR PLEASE MAKE A VIDEO ON PAYPAL PAYOUT USING PHP

    Reply
  • January 10, 2019 at 6:07 am
    Permalink

    Do we need to do this for a donation button as well?

    Reply
  • January 10, 2019 at 4:23 pm
    Permalink

    Is it also true that not all free webhosting supports listener.php? I tried it with a few webhosting services and the listener file doesn't work for some of them… I guess if anyone else is having issue with this then this could be one reason why it doesn't work…

    Reply
  • January 11, 2019 at 11:49 am
    Permalink

    Hello , paypal ipn simulator works but does not work in real transaction. Do you have the solution?

    Reply
  • January 11, 2019 at 8:16 pm
    Permalink

    hey i admire your work you are a true mentor please do you have a video on shopping card

    Reply
  • January 17, 2019 at 3:55 pm
    Permalink

    I'm from Cambodia, I don't why I can not register within Sandbox account with paypal

    Reply
  • January 27, 2019 at 10:01 pm
    Permalink

    you are dedicated Thanks 🙂

    Reply
  • February 11, 2019 at 11:50 pm
    Permalink

    I think i am in love with you… Great tutorial

    Reply
  • February 12, 2019 at 9:08 pm
    Permalink

    I'm for about 3 days trying soo hard, and I dont find why I get Invalid in Txt file after IPN Testing, hand shake confirmed.
    Please Master Coding save me

    *! Update. (I Figured out how to solve this problem Coding Passive, I had really much difficult to get verified and not invalid anymore, please have a look on this code I founded on internet which solved my problem)

    <?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
    $response = curl_exec($ch);
    curl_close($ch);
    $file = fopen('test.txt','w') or die('unable to open');
    fwrite($file, $txt);
    fclose($file);
    ?>

    $raw_post_data = file_get_contents('php://input');
    $raw_post_array = explode('&', $raw_post_data);
    $myPost = array();
    foreach ($raw_post_array as $keyval) {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
    $myPost[$keyval[0]] = urldecode($keyval[1]);
    }
    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    if(function_exists('get_magic_quotes_gpc')) {
    $get_magic_quotes_exists = true;
    }
    foreach ($myPost as $key => $value) {
    if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
    $value = urlencode(stripslashes($value));
    } else {
    $value = urlencode($value);
    }
    $req .= "&$key=$value";
    }

    Reply
  • February 14, 2019 at 6:36 pm
    Permalink

    what is the problem if reserve this Alart "IPN was not sent, and the handshake was not verified. Review your information."

    Reply
  • February 21, 2019 at 10:50 pm
    Permalink

    Hi. Do you know how to implement buy now button for thousands of products at once?

    Reply
  • February 26, 2019 at 1:49 am
    Permalink

    Love your Tutorials, but you have a idea how the buyer can give me his adress before purchusing? Because wen he buy somethink now i dont no were i have to send the Product?

    Reply
  • March 1, 2019 at 3:25 am
    Permalink

    I have one question in this video we create one button for one product and set the price on paypal according to product but in live website where thousands of products how to handle that scenario is we have to create button for each product?

    Reply
  • March 1, 2019 at 9:23 am
    Permalink

    This tut 100% and thank you for 42.12 nice and nice and nice *_+

    Reply
  • March 6, 2019 at 8:49 pm
    Permalink

    Hi my friend why ipn restores me an empty matrix error!
    I have tried on the local server not only working online but do not know the reason for not liking
    I will put you my code!!

    Reply
  • March 20, 2019 at 1:16 am
    Permalink

    nice video. i guess if you would win 10 million dollar you would just say ok.. cool… go home and sleep just like nothing happened 😀

    Reply
  • March 22, 2019 at 4:43 am
    Permalink

    Key times in video:
    HTML/CSS framework and page 0:00
    PayPal Button (Find and Create): 10:02
    PayPal Button Take Notice! of these details 11:43
    PayPal Button Configure IPN Listener Test! (simulator) 14:50
    Code the listener File START 18:39 – 25:18 END (That VERIFIED resonse is the beginning of your payment handler or what you want to do with it)
    Do something once VERIFIED like Get the HTML variable list possible in POST 27:51
    Some troubleshooting recommendations and techniques 33:14–34:53 END of practicality.

    Rest of the video is how to do something with a VERIFIED response and that is sending an e-mail to a customer or payer.

    Enjoy!

    Reply
  • March 29, 2019 at 9:07 pm
    Permalink

    Hi! I got an issue 🙁 In listener.php I got sql query to dabase that changes type of subscription (just text: from standard to ext. gold). The problem is that this query doesn't see $_SESSION['id] which is session variable for my documents. So my question is how to solve this? How to give information about this variable in this document when only PayPal is integrating with this file?

    Reply
  • April 14, 2019 at 8:43 pm
    Permalink

    The EMail isn't working

    Reply
  • April 16, 2019 at 1:40 am
    Permalink

    Hello friend! Can you contact me because i need a custom script from you.

    Reply
  • April 18, 2019 at 12:18 pm
    Permalink

    Thanks, bro. That really helped me

    Reply
  • May 26, 2019 at 4:31 pm
    Permalink

    thank you sir

    Reply
  • May 26, 2019 at 4:33 pm
    Permalink

    Does this still work in 2019? Where do you get that form to start typing php codes? Thanks.

    Reply
  • May 30, 2019 at 7:00 am
    Permalink

    For people who are having trouble with the test.txt file, first create the file in the server and set read/write permissions by all.

    Reply
  • June 3, 2019 at 8:05 pm
    Permalink

    Great Jobe Man, you are awesome 🤟🏼

    Reply
  • June 4, 2019 at 11:42 am
    Permalink

    LOL. I wonder what's in that favorites folder After 9PM! jk,…Great video… helped me a lot.

    Reply
  • June 5, 2019 at 12:52 am
    Permalink

    hello can you do a tutorial for multiple IPNs in one paypal account ( people normally have > 1 website with one paypal account)

    Reply
  • June 13, 2019 at 2:33 pm
    Permalink

    Thank you very much!! It's working!

    Reply
  • June 16, 2019 at 2:29 pm
    Permalink

    Is there any other method if my free webhosting does not support api? Can we just add a paypal button?

    Reply
  • June 29, 2019 at 5:40 am
    Permalink

    How can we use this for a donation button?

    Reply
  • June 30, 2019 at 12:25 pm
    Permalink

    Thanks much sir, your tutorials has taken me to another level in web based apps developments!!!

    Reply
  • July 3, 2019 at 8:03 am
    Permalink

    why do we set the verifyhost and verify peer to 0? isn't it better to set it to 1?

    Reply
  • July 18, 2019 at 5:58 pm
    Permalink

    Thank you for the detailed explanation of papal integration

    Reply
  • July 29, 2019 at 3:32 pm
    Permalink

    Hi! This is a great tutorial for me. I just want to ask if this API services has a 3-D secure? Can I use this without 3-D secure? Secondly, is this API safe from scams and frauds? Hopefully you will answer my question. Thank you!

    Reply
  • July 30, 2019 at 7:08 pm
    Permalink

    FIX CODE
    1) Php no longer accept "filename: path" but you have to insert $path (Example: file_put_contents($path, $response)
    2) Same for fwrite. Instead of "string: $key" you have to delete "string:"

    Reply
  • July 30, 2019 at 8:58 pm
    Permalink

    QUESTION
    What if i want send with POST method some variables to listener?
    Example in dates.php you chose 2 dates. After send to listener and put, with query, dates in database.

    Reply
  • July 31, 2019 at 12:45 am
    Permalink

    Kudos

    Reply
  • August 9, 2019 at 4:39 pm
    Permalink

    i create the button as you do but when i click it at 14:07 as you do nothing happen. the only different think that i do was that i left empty the Add advanced variables because i didnt understand what that is. Can anyone help me please???

    Reply
  • August 11, 2019 at 12:40 am
    Permalink

    Does it still works?

    Reply
  • August 21, 2019 at 12:17 pm
    Permalink

    Amaizing man

    Reply
  • September 2, 2019 at 12:21 am
    Permalink

    Great tutorial sir

    Reply
  • September 12, 2019 at 6:01 pm
    Permalink

    Nice, would you please make paypal check out with dynamic price for ecommerce ?

    Reply
  • October 2, 2019 at 4:08 am
    Permalink

    Good video, now go next level, made it clear and beautiful with interfaces, abstracts, classes ? 🙂

    Reply
  • November 9, 2019 at 11:08 am
    Permalink

    if i have have thousands of products in my website, then i will have to create lots of buttons.is there any other way that i can do shortly ? for example i want to change the price(value) of the buynow button within my page using php.

    Reply
  • November 19, 2019 at 3:40 pm
    Permalink

    You spent the first 10 minutes on CSS, borders…

    Reply
  • December 6, 2019 at 10:35 am
    Permalink

    They didn't give source code free time waste to serach

    Reply
  • January 5, 2020 at 10:37 pm
    Permalink

    Thanks for video tutorial. But now thinking…if instead of sending an email , i want in my webpage to show some random result to the payer…? Payer, enters some words (for example 100 words in textarea), to check if the words exists in my database. I show payment button. Payer pays. Listener receives and checks Paypal response. …. and here i can not understand how to continue to process entered (textarea) data… Any ideas?

    Reply
  • January 11, 2020 at 12:52 pm
    Permalink

    how to listen for multiple fields(if more than one item_name1,itemname2 etc etc) in an ipn here is my code i am not getting any item_name in return
    ,thanks in return
    $raw_post_data = file_get_contents('php://input');

    $raw_post_array = explode('&', $raw_post_data);

    $myPost = array();

    foreach ($raw_post_array as $keyval) {

    $keyval = explode ('=', $keyval);

    if (count($keyval) == 2)

    $myPost[$keyval[0]] = urldecode($keyval[1]);

    }

    $req = 'cmd=_notify-validate';

    if(function_exists('get_magic_quotes_gpc')) {

    $get_magic_quotes_exists = true;

    }

    foreach ($myPost as $key => $value) {

    if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {

    $value = urlencode(stripslashes($value));

    } else {

    $value = urlencode($value);

    }

    $req .= "&$key=$value";

    }

    /*

    * Post IPN data back to PayPal to validate the IPN data is genuine

    * Without this step anyone can fake IPN data

    */

    $paypalURL = PAYPAL_URL;

    $ch = curl_init($paypalURL);

    if ($ch == FALSE) {

    return FALSE;

    }

    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

    curl_setopt($ch, CURLOPT_POST, 1);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);

    curl_setopt($ch, CURLOPT_SSLVERSION, 6);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

    curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);

    // Set TCP timeout to 30 seconds

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);

    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close', 'User-Agent: company-name'));

    $res = curl_exec($ch);

    /*

    * Inspect IPN validation result and act accordingly

    * Split response headers and payload, a better way for strcmp

    */

    $tokens = explode("rnrn", trim($res));

    $res = trim(end($tokens));

    if (strcmp($res, "VERIFIED") == 0 || strcasecmp($res, "VERIFIED") == 0) {

    // Retrieve transaction info from PayPal

    $item_number = $_POST['item_number'];

    $txn_id = $_POST['txn_id'];

    $payment_gross = $_POST['mc_gross'];

    $currency_code = $_POST['mc_currency'];

    $payment_status = $_POST['payment_status'];

    // Check if transaction data exists with the same TXN ID

    $prevPayment = $db->query("SELECT payment_id FROM payments WHERE txn_id = '".$txn_id."'");

    if($prevPayment->num_rows > 0){

    exit();

    }else{

    // Insert transaction data into the database

    $insert = $db->query("INSERT INTO payments_paypal(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");

    }

    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *