• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[PHP] DaoPay API

Chris

Inactive
Senator
Joined
Aug 11, 2008
Messages
2,628
Solutions
2
Reaction score
240
As my old DaoPay API topic in the donor board was bumped the other day I decided to give it a face-lift. This time I will release it for everyone and not just the donors. I am not planning to create a tutorial on the basics of PHP so this tutorial assumes that you have some of that basic PHP knowledge. Anyway, you can find the two classes (one for the DaoPay API and one for the log file) in the link below.

Download: [URL="http://api.madphp.org/daopay/index.php"]DaoPay API © Absolute Mango
[/URL]

The first thing you should do is to modify the database and daopay data (they can be located in the DaoPay API private variables section).

Method List (only those with public access):

  • $daopay->_getPremiumPoints()
  • $daopay->_setPremiumPoints(points, reset)
  • $daopay->_checkPinValidation(pin)
  • Log::newEntry(string)


Example #1:
You can easily add an amount of premium points to a specific character without doing lots of code. When creating a new DaoPay object you are allowed to enter 2 parameters, the first one should contain the name or the id of the character you wish to deal points to (this is a required parameter). The second one should contain the amount of premium points that the character should receive (this is an optional parameter, default is set to 0).
PHP:
$daopay = new DaoPay('Account Manager', 30);
unset($daopay);
Example #2:
Lets say you would like to verify the pincode that you receive from DaoPay, and if it turns out to be valid you would like to give the character a few premium points - otherwise do not give the character any points.
PHP:
$daopay = new DaoPay('Account Manager');
if($daopay->_checkPinValidation('emaheoalsc')) {
    $daopay->_setPremiumPoints(30);
}
unset($daopay);
Example #3:
Now lets imagine that you would like to give out 10 premium points to the character in case he currently posses 0 premium points. If he has more than 0 points you would only like to give 5.
PHP:
$daopay = new DaoPay('Account Manager');
if($daopay->_checkPinValidation($_POST['pin'])) {
    if($daopay->_getPremiumPoints() == 0) {
        $daopay->_setPremiumPoints(10);
    } else {
        $daopay->_setPremiumPoints(5);
    }
}
unset($daopay);
Example #4:
This time you would like to do the same as in the example above, but you would also like to save the entry in a log file.
PHP:
$daopay = new DaoPay($_POST['character']);
if($daopay->_checkPinValidation($_POST['pin'])) {
    if($daopay->_getPremiumPoints() == 0) {
        $daopay->_setPremiumPoints(10);
    } else {
         $daopay->_setPremiumPoints(5);
    }
    Log::newEntry('Pin: '.$_POST['pin'].' - Character: '.$_POST['character'].' - Time: '.date('d/m/Y H:i:s'));
}
unset($daopay);
Example #5:
Lets say that you wish to reset that characters points if they are already above 50 and then add 50 new points (making his total to 50). You would then have to set the second optional parameter in the _setPremiumPoints() method to true (meaning it would reset his current points before adding the new ones (it is false by default)).
PHP:
$daopay = new DaoPay($_POST['character']);
if($daopay->_checkPinValidation($_POST['pin'])) {
    if($daopay->_getPremiumPoints() > 50) {
        $daopay->_setPremiumPoints(50, true);
    }
}
unset($daopay);
As I said at the very top of this topic, I am not going to explain how if statements, variables or any basic PHP scripting works. You would still have to create the actual form. You can get the order number and the pin code by using $_GET as DaoPay redirects you with a finished querystring.

Good luck!
 
Last edited:
Thank you for the comments. :>
 
Also considering making a PayPal API.
 
Added a fifth example on how to reset someone's premium points to zero before adding the new ones.
 
:( the php isn't working for me, added it to index.php

PHP:
Parse error:  syntax error, unexpected ',' in C:\xampp\htdocs\daopay.php on line 559

is it me or this isn't a php page/
 
Sorry about that, find this line:
PHP:
public static function newEntry($string, $file = 'transactions.log') {
and change the return true, to return true;
 
nah it's ok i'd better use gesior's
but is yours better?

btw do you think you could help with a highscore php script, related to text-on-image like your signatures?
 
I'm not sure whether mine is better or not as I haven't seen his (the actual code for it), however mine is merely an API and not a finished product.

Yeah sure thing, what exactly is it that you need assistance with?
 
:D don't matter, I know you're a good programmer

what I want is a php highscore page for my rep system
1. I need 2 rows of results separated, but I can't manage to do it
2. Idk how to make sql results appear on two images :( can I pm you the codes?
 
Back
Top