PHP code example of grandmasterx / skrill

1. Go to this page and download the library: Download grandmasterx/skrill library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grandmasterx / skrill example snippets


use grandmasterx\Skrill\Models\QuickCheckout;

$quickCheckout = new QuickCheckout([
    'pay_to_email' => '[email protected]',
    'amount' => 100500,
    'currency' => 'EUR'
]);

/*
You can also use setters to bind parameters to model
If you want to see all list of parameters just open QuickCheckout file
Each class attribute has description
*/
$quickCheckout->setReturnUrl('https://my-domain.com');
$quickCheckout->setReturnUrlTarget(QuickCheckout::URL_TARGET_BLANK);

use grandmasterx\Skrill\Models\QuickCheckoutForm;

$form = new QuickCheckoutForm($quickCheckout);

echo $form->open([
    'class' => 'skrill-form'
]);

/*
By default all fields will be rendered as hidden inputs
If you need to render some field as visible (i.e. amount of payment) you should specify it in $exclude
Excluded fields will not be rendered at all - you should render them by yourself
*/
$exclude = ['amount'];
echo $form->renderHidden($exclude);
<input type="text" name="amount"> .....
echo $form->renderSubmit('Pay', ['class' => 'btn']);
echo $form->close();

use grandmasterx\Skrill\Models\SkrillStatusResponse;
use grandmasterx\Skrill\Components\SkrillException;

try {
    $response = new SkrillStatusResponse($_POST);
} catch (SkrillException $e) {
    # something bad in request
}

/*
SkrillStatusResponse model contains attributes only for 
    # Note that you should enable receiving failure code in Skrill account before
    # It will not provided with default settings
    $errorCode = $response->getFailedReasonCode();
}

/*
Also you can retrieve any Skrill response parameter and make extra validation you want.
To see all Skrill response parameters just view SkrillStatusResponse class attributes
For example:
*/
if ($response->getPayToEmail() !== '[email protected]') {
    // hum, it's very strange ...
}

/* Also you can log Skrill response data using simple built-in logger */
$response->log('/path/to/writable/file');