DonationClaim

Moved

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

5/5, 7 likes
  1. Any fix for the SQL error in LINE 4?
     
  2. Who's your webhost? There isn't anything inherently wrong with LINE 4, but depending on some environmental variables, you could try changing the delimiter as has been previously suggested... Or if your host is like mine, you may need to use a wizard/tool they provide to setup the routine (procedure) in lieu of the script provided here.

    Back to my issues: I have gotten everything working, but my host again introduced a new obstacle. Only connections made from my web server can bridge connections to my web servers database. (Which means the plugin, on my game server, is forcefully rejected when trying to connect.)

    My workaround is that I'm writing a plugin that will do some push/pull requests to some php code that will handle calling the stored procedures and returning identifiable data to accredit the donation. Works great, but I have a few things I need to clean up.
     
  3. Hosted on my windows server using wamp.

    Tried to validate the SQL using online validators and they all failed.

    Hopefully you can get this plugin up and going would be great.

    Edit: Got the thing to work by taking out the delimiter identifier however upon IPN handshakes no data is being saved to database, tried making a new user with host set to %, ive set the link to sandbox.paypal.com still not working.

    I have a feeling it's the SQL we've all had issues with if anyone could reply with something that worked for them because on newer SQL server versions it appears that it doesn't work.
     
    Last edited by a moderator: Jul 15, 2016
  4. Please see my reply at the bottom of page 2. It's the Boolean return check on $fp failing due to PayPals recently updated requirements to OpenSSL. Comment out that if check, and it will work. I can post an example when I get home.

    The SQL is completely fine.
     

  5. If you could do that then that would be great, getting errors from the plugin while doing /claim but I think that's related to the table not containing any data.
     
  6. Actually, I apologize but I won't be able to leave an example. Due to the fact my web host doesn't allow external connections to be made directly to my databases, I had to completely rewrite the C# plugin to trigger the stored procedure via a GET request and a custom php listener. This inherently required some changes to the rest of the code. Once I finish building the rest of my plugin's features, I will look to share. I'm sure my host isn't the only one this annoying, so others might benefit from having a GET version vs. MySQL.

    I would be happy to help you over Skype or something with your system though. That would give me the opportunity to track the specific steps I take to fix it so that I could be of more help to this thread.
     
    Last edited by a moderator: Jul 16, 2016
  7. Huge shoutout to @Neonic_State, everything is working perfectly fine now.
     
  8. I don't do long posts often, so it's possible I screwed something up here. For those still experiencing issues, here's a link I found that goes into more detail about why you're facing the problems you are. (Knowledge is power, don't just read this and take my word for it.)

    I don't know why, but the Lang helper gave me a headache so I just said the hell with it. (I'd love for someone to explain how to fix it instead.) Here's a brief overview how the PayPal IPN system works... High level...
    1. You get a payment, and PayPal sends over a page of data to your Listener.
    2. Your listener takes it, and literally regurgitates it back at PayPal over HTTPS.
    3. PayPal says Yep, that's what I sent you.
    4. Your listener says Cool, if it's verified then let's add it to the database.
    Important part is the HTTPS piece. It is required when using sandbox.paypal ... or you can ignore PayPal's validation and insert whatever gets POST'd willy nilly. Not really my cup of tea. HTTPS is not required though for LIVE until June 2017. Here are the steps to make it work:

    Code:
    DonationClaim.cs
        REPLACE: Reply(player, Lang("NoUnclaimed", player.Id), playerEmail.Replace("@@", "@"));
           WITH: Reply(player, "No unclaimed rewards available for email address: " + playerEmail.Replace("@@", "@"));
        
        REPLACE: Reply(player, Lang("Claimed", player.Id), packageClaimed);
           WITH: Reply(player, "You claimed the "+packageClaimed+ " donation package. Thank you for your donation!");
        
        REPLACE: Reply(player, Lang("NoPackage", player.Id), packageClaimed);
           WITH: Reply(player, "Package "+packageClaimed+" could not be found! Please notify an admin");PayPal Listener File - NAME THIS SOMETHING UNIQUE. Store somewhere not obvious. Not a fan of the generic name instructed here.
        Add Line: If(!ISSET($_POST['txn_id'])){die();}
            Wher: Anywhere AFTER the <?php and before the foreach
             Why: Stops empty entries if for whatever reason someone directly opens the listener in a browser.
     
        Add Line: error_reporting(0);
            Wher: Line right below <?php
             Why: Remove this for testing, but when going live this will stop errors that could aid spoof attempts.     REPLACE: $header .= "Host: www.paypal.com\r\n"; //Change this to www.sandbox.paypal.com\r\n for testing
            WITH: $header .= "Host: https://ipnpb.sandbox.paypal.com\r\n"; //Change this to https://ipnpb.sandbox.paypal.com\r\n for testing
        
         REPLACE: $fp = fsockopen ('www.paypal.com');  // Change this to ssl://www.sandbox.paypal.com for testing
            WITH: $fp = fsockopen ('https://ipnpb.sandbox.paypal.com', 443, $errno, $errstr, 30);  // Change this to https://ipnpb.sandbox.paypal.com for testing
    No SSL? Use This instead: $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);  // Change this to https://ipnpb.sandbox.paypal.com and port 443 for testing
        
        
        DOES YOUR SITE MEET THESE REQUIREMENTS: https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1916&viewlocale=en_US
        YES: Please let me know who your web host is, mine refuses. You're good to go.
         NO: You cannot validate your data with PayPal on the Sandbox. Until June 2017, you can still do HTTP postbacks on the live system. But come June 2017, everything will require SSL. This presents a tricky situation, because you can't test your code on Sandbox unless you have adequate SSL packages. To TEST ON SANDBOX... you can do the following: Comment out lines in the listener: 13-18, 26-33, 56-61, and 64. Do NOT and I repeat, do NOT comment those lines out when Live. If you do, I'm not responsible for whatever is injected into your database.
    And if anyone is interested in a version of this plugin that doesn't connect the Plugin->MySQL, let me know. My server doesn't allow outside connections to it, so I had to build my own. (It's still 70-80% Wulf's code/concept though, so the credit is still all there.)
     
  9. Wulf

    Wulf Community Admin

    I don't see a need to replace the Lang lines. ;)
     
  10. Stock plugin doesn't work, error on /claim.

    @Neonic_State changed a few lines in the plugin as stated above which made it work fine, seems as if it fails to refer back to the lang.
     
  11. Wulf

    Wulf Community Admin

    You'd just need to fix the reason it is erroring then, not make it static. Will be fixed in the next version shrotly.
     
  12. I'm new to the oxide mod. I mentioned in my post I'd love to know what was wrong, but I couldn't be arsed with letting a helper function prevent me from having a working plugin.

    I don't recall the specific error anymore... Something about converting #1 to byte or etc. But removing its usage did in fact fix everything :).
     
  13. Wulf

    Wulf Community Admin

    I'm pretty sure I know what it was, but for future reference, if you can provide the errors it would help with the developer of the plugin. ;)
     
  14. Well quite frankly, I didn't want the stock version to work. I knew it would never work for my specific/unique needs, so I apologize but I did it my way for my needs. I hope the information I've provided you helps you fix it for your users. Almost every error mentioned in this thread is fixed by something I said in one of my posts, as I've tested by fixing the issues of one of the posters in this thread.
     
  15. Wulf

    Wulf Community Admin

    No need to apologize, no harm in modifying, and I appreciate the help as I haven't been able to test it much myself since porting it over from the original author as a universal plugin. I just don't want to encourage removing the Lang API as it is there to allow easier translation of messages and localization, hence the desire to fix it rather than remove it. :)
     
  16. I have it all set-up and it seems to be working except for when it goes to run the commands.
    When I run the VIP90, It is just trying to run the default and not what I entered.
    When I run the Donator it has an SQL error

    Any idea what I am doing wrong?

    I have confirmed the commands work in RCON
    I have removed and let the config rebuild and only modified the commands as per below, then restarted the plugin: (DB user info replaced)
    Code:
    {
      "DatabaseHost": "localhost",
      "DatabaseName": "oxide",
      "DatabasePassword": "PASSWORD",
      "DatabasePort": 3306,
      "DatabaseUser": "USER",
      "Packages": {
        "Donator": [
          "oxide.usergroup add {steamid} donator"
        ],
        "VIP90": [
          "addgroup {steamid} viptimed 90d",
          "oxide.usergroup add {steamid} donator"
        ]
      }
    }
    When I try to claim the VIP90, problem is it doesn't seem to read the config.
    In game I get:
    "You claimed the VIP90
    donation package. Thank you for the donation!"

    In console I get:
    (21:05:16) | [Oxide] 21:05 [Info] [DonationClaim] Package Claimed: VIP90
    (21:05:16) | [Oxide] 21:05 [Info] Permission 'some.permission' doesn't exist
    (21:05:16) | [Oxide] 21:05 [Info] Permission 'another.permission' doesn't exist

    When I try to claim the Donator, It has an SQL error as per below.
    Code:
    (21:16:44) | [Oxide] 21:16 [Info] [DonationClaim] Package Claimed: Donator
    (21:16:44) | [Oxide] 21:16 [Error] MySql command callback raised an exception (FormatException: Input string was not in a correct format.)
    (21:16:44) | [Oxide] 21:16 [Debug] at System.String.ParseFormatSpecifier (System.String str, System.Int32& ptr, System.Int32& n, System.Int32& width, System.Boolean& left_align, System.String& format) [0x00000] in <filename unknown>:0
    at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
    at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
    at System.String.Format (System.String format, System.Object arg0) [0x00000] in <filename unknown>:0
    at Oxide.Plugins.DonationClaim.RunConsoleCommands (System.Collections.Generic.List`1 commandsList, System.String playerName) [0x00000] in <filename unknown>:0
    at Oxide.Plugins.DonationClaim+<ChatCommand>c__AnonStorey0.<>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
    at Oxide.Ext.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
     
    Last edited by a moderator: Aug 28, 2016
  17. The command to grant them the permissions is incorrect friend. It should be something to the tune of

    grant user {0} donationclaim.donator

    Where "donator" is the individual name of the package they are requesting. Same goes for the other packages in your error report.

    As for the SQL error, I just woke up and rolled over and grabbed my phone. Fix the permission string above, and if you're still getting a SQL Error... I'll probably have gotten some coffee by then.
     
  18. Thank you for the reply.
    1stly I had made a dumb assumption that steamid would work. My bad.
    Once I changed the steamid to {0} the SQL error went away and the Donator package worked fine.

    2nd, after a lot of testing I found that you cannot use the word VIP in any package name as it tries to call the default VIP package that isn't in the config.
    I tried many things and could not get any of the other packages to work until I renamed them all without VIP in the names.
    It all works perfectly since I removed the word VIP from each package.
    The command "addgroup {0} viptimed 90d" is command line for TimedPermission. it works now as well.
    Code:
      "Packages": {
        "Donator": [
          "oxide.usergroup add {0} donator"
        ],
        "30": [
          "addgroup {0} viptimed 30d",
          "oxide.usergroup add {0} donator"
        ],
        "60": [
          "addgroup {0} viptimed 60d",
          "oxide.usergroup add {0} donator"
        ],
        "90": [
          "addgroup {0} viptimed 90d",
          "oxide.usergroup add {0} donator"
        ],
        "Life": [
          "oxide.usergroup add {0} viptimed"
        ]
      }
     
    Last edited by a moderator: Aug 28, 2016
  19. Wulf

    Wulf Community Admin

    Does it what?