DonationClaim

Players can claim rewards for automatic PayPal donations

Total Downloads: 470 - First Release: May 20, 2016 - Last Update: Nov 10, 2016

5/5, 6 likes
  1. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Wulf submitted a new resource:

    DonationClaim - Players can claim rewards for automatic PayPal donations

    Read more about this resource...
     
  2. 4lex

    4lex Wood Hoarder

    Will items from a cart work, or do the items have to be individually purchased
     
  3. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    I've not tested that, but feel free to try.
     
  4. timp111222

    timp111222 Wood Hoarder

    I get error at line 4 on the secound mysql thing
     
  5. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    What is the error? I can't guess your error. ;)
     
  6. timp111222

    timp111222 Wood Hoarder

    #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 '' at line 4
     
  7. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Could you show me a screenshot of what you copied and what line 4 is to you? The syntax on the Overview is valid though.
     
  8. timp111222

    timp111222 Wood Hoarder

    idk if i did anything right... Screenshot
     
  9. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Try removing the blank lines and see what happens. Might be an issue with how it was copied.
     
  10. timp111222

    timp111222 Wood Hoarder

    Didnt help, is there anything i need to change in the lines? :)
     
  11. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    No, it looks fine. The only other thing I can think of is that the version of MySQL you have doesn't support that syntax. I'm not that familiar with MySQL though anymore, so I may have to dig around a bit for an answer.
     
  12. timp111222

    timp111222 Wood Hoarder

    Hmm.. Kinda want this to work :D
    --- Double Post Merged, May 20, 2016 ---
    I spoke with my mysql host and they say this:

    Code (Text):
    I am sorry, but this SQL query looks incomplete for me. I would recommend to contact developers of this plugin, they should be able to assist you better.
    --- Double Post Merged, May 20, 2016 ---
    Installed mysql server on my pc and doesnt work here either..
    --- Double Post Merged, May 20, 2016 ---
    Do you got skype or anything? nothing works..
     
  13. Atsunra

    Atsunra Scavenger

    It works for HurtWorld ?
     
  14. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yes, it should.
    --- Double Post Merged, May 21, 2016, Original Post Date: May 21, 2016 ---
    I'm not sure, I copied from the original developer's post. I ran it through SQL tests and it came back as valid. I'll test more when I get a chance, or scrap the idea of MySQL and use something more direct.
     
    Atsunra likes this.
  15. timp111222

    timp111222 Wood Hoarder

    Okay :) any news? :D
    --- Double Post Merged, May 22, 2016 ---
    no?
     
  16. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Not yet, I don't have a setup to set it with, but everything so far shows that SQL is valid.
     
  17. timp111222

    timp111222 Wood Hoarder

    Do you got skype or anything? so i can show u whats happening..
     
  18. Mr. Tea

    Mr. Tea Naked Wanderer

    I've set up the listener and MySQL Credentials file and have used the IPN Simulator which returns 'IPN Was sent and the handshake was verified' however the data is not written to the ibn_table. Here are my snippets of code, my database is named c1302212_rust rather than oxide so I changed oxide.ibn_table to c1302212_rust.ibn_table where appropriate however I still can not get my code to work.

    Code (Text):
    <?php

    include 'mysqlcredentials.php';
    //read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';

    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }

    // Post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Host: www.sandbox.paypal.com\r\n"; //Change this to www.sandbox.paypal.com\r\n for testing
    $header .= "Connection: close\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);  // Change this to ssl://www.sandbox.paypal.com for testing

    // Error connecting to PayPal
    if (!$fp) {
        // TODO
    }

    // Successful connection
    if ($fp) {
        fputs ($fp, $header . $req);

        while (!feof($fp)) {
            $res = fgets ($fp, 1024);
            $res = trim($res); //NEW & IMPORTANT

            if (strcmp($res, "VERIFIED") == 0) {
                $transaction_id = $_POST['txn_id'];
                $payerid = $_POST['payer_id'];
                $firstname = $_POST['first_name'];
                $lastname = $_POST['last_name'];
                $payeremail = $_POST['payer_email'];
                $paymentdate = $_POST['payment_date'];
                $paymentstatus = $_POST['payment_status'];
                $mdate= date('Y-m-d h:i:s',strtotime($paymentdate));
                $otherstuff = json_encode($_POST);
                $item_name = $_POST['item_name'];
                $conn = new mysqli($dbhost,$dbusername,$dbpassword);
                if ($conn->connect_error) {
                    trigger_error('Database connection failed: '  . $conn->connect_error, E_USER_ERROR);
                }
                // insert in our IPN record table
                $query = "INSERT INTO c1302212_rust.ibn_table
                (itransaction_id,ipayerid,iname,iemail,itransaction_date, ipaymentstatus,ieverything_else,item_name)
                VALUES
                ('$transaction_id','$payerid','$firstname $lastname','$payeremail','$mdate','$paymentstatus','$otherstuff','$item_name')";
                $result = $conn->query($query);
           
                $conn->close();
            }

            if (strcmp ($res, "INVALID") == 0) {
                //insert into DB in a table for bad payments for you to process later
            }
        }

        fclose($fp);
    }

    ?>
    Code (Text):
    DROP PROCEDURE IF EXISTS `claim_donation`;

    CREATE DEFINER = `c1302212_rust`@`localhost` PROCEDURE `claim_donation`(IN `email_address` varchar(255))
    BEGIN

    set email_address = REPLACE(email_address,'@@','@');

    set @ID = (
    select    IBN.id
    from    c1302212_rust.ibn_table as IBN
    where    IBN.iemail = email_address
            and IBN.claimed = 0
            and IBN.claim_date IS NULL
            and IBN.ipaymentstatus = "Completed"
    ORDER BY IBN.itransaction_date DESC
    LIMIT 1);

    UPDATE c1302212_rust.ibn_table
    SET    claimed = 1, claim_date = NOW()
    WHERE id = @ID;

    select    IBN.item_name
    from    c1302212_rust.ibn_table as IBN
    where    IBN.id = @ID;

    END;
     
    Code (Text):
    DROP TABLE IF EXISTS `ibn_table`;
    CREATE TABLE `ibn_table` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `itransaction_id` varchar(60) NOT NULL,
      `ipayerid` varchar(60) NOT NULL,
      `iname` varchar(60) NOT NULL,
      `iemail` varchar(60) NOT NULL,
      `itransaction_date` datetime NOT NULL,
      `ipaymentstatus` varchar(60) NOT NULL,
      `ieverything_else` text NOT NULL,
      `item_name` varchar(255) NOT NULL,
      `claimed` int(11) NOT NULL,
      `claim_date` datetime DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
     
    Last edited: May 25, 2016
  19. Acti0n3062

    Acti0n3062 Naked Wanderer

    I Have the same Error...
    Any news to fix this?
     
  20. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    No, someone with more MySQL experience would need to chime in. I simply copied what the original author had.