I have published a beta package of the Maniaplanet Web Services SDK. this new version add a new feature for you. Thanks to it, you will be able to create transaction with various cost, or with a dynamic recipient (like on ManiaLoto).
To do it, it's pretty simple if you respect the following documentation.
First step
Creating the transaction.
First you have to create a transaction.
Code: Select all
$t = new \Maniaplanet\WebServices\Transaction();
$t->creatorLogin = 'YourLogin';
$t->creatorPassword = 'YourAccountPassword';
$t->creatorSecurityKey = 'YourValidationKey';
$t->fromLogin = 'thePlayerWhoWillPay';
$t->toLogin = 'thePlayerWhoWillBePaid';
$t->cost = xxx; //The amount the current player have to pay.
$t->message = 'SomethingToIdentifytheTransaction';
$p = new \Maniaplanet\WebServices\Payments('APIUsername','APIPassword');
$idTransaction = $p->create($t);
Pay the transaction.
To be paid, you just have to redirect the player on a short url with the id of transaction as GET parameter.
e.g: Here is a sample of url to be paied
Code: Select all
manialoto?transaction=idTransaction
Check the payment
Once the player has choose to pay or not to access to your page, you have to test, if the payment have been made.
To check the payment you have to call the second method of the payment class, here is an example:
Code: Select all
$idTransaction = $_GET['transaction'];
$p = new \Maniaplanet\WebServices\Paiements('APIUsername','APIPassword');
if($p->isPaid($idTransaction))
{
//Do Some stuff if it's paid
}
else
{
//Do Some stuff if it's not paid
}
We will release a new package very soon.