- 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):
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).
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.
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.
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.
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)).
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!
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);
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);
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);
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);
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);
Good luck!
Last edited: