PHP code example of jpaypp / jpay-skrillpay-php

1. Go to this page and download the library: Download jpaypp/jpay-skrillpay-php 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/ */

    

jpaypp / jpay-skrillpay-php example snippets






$skrill = new ApiContext(
    new OAuthTokenCredential(
        '[email protected]',
        'skrill',
        'skrill123'
    )
);

$skrill->setConfig(
    array(
        'mode' => 'live',
        'log.LogEnabled' => true,
        'log.FileName' => APPS_PATH .'/../logs/SkrillPay.log',
        'log.LogLevel' => 'INFO', // PLEASE USE `INFO` LEVEL FOR LOGGING IN LIVE ENVIRONMENTS
        'cache.enabled' => false,
        'http.CURLOPT_CONNECTTIMEOUT' => 30
    )
);




$payer = new Payer();
$payer->setPaymentMethod('quick');


$payerInfo = new PayerInfo();

$payerInfo->setPayToEmail($skrill->getCredential()->getClientId())
    ->setLogoUrl('company logo url')
    ->setRecipientDescription('http://xxxx/company desc')
    ->setTransactionId(time())

    ->setReturnUrl('http://xxxx/callback.html')
    ->setReturnUrlTarget('_self')
    ->setReturnUrlText('返回信息描述')

    ->setCancelUrl('cancle.html')
    ->setCancelUrlTarget('_self')

    ->setStatusUrl('http://xxxx/notify.html');


$amount = new Amount();

$amount->setCurrency("EUR")
       ->setAmount('1')
       ->setDetail1Text('test')
       ->setDetail1Description('年费会员');

$checkout = new Checkout();

$checkout->setPayer($payer) //base
    ->setPayerInfo($payerInfo)  //merchant
    ->setCustomer( new Customer()) //customer
    ->setAmount($amount) //amount
    ->setPrepareOnly('1');  //generate a SID

try {
    $checkout->create($skrill);
} catch (\Exception $e) {
    echo json_encode(array('code'=>201,'data'=>$e->getMessage()))."\r\n";
    die();
}

$approvalUrl = $checkout->getApprovalLink();




$skrill = new ApiContext(
    new OAuthTokenCredential(
        '[email protected]',
        'skrill',
        'skrill123'
    )
);

$skrill->setConfig(
    array(
        'mode' => 'live',
        'log.LogEnabled' => true,
        'log.FileName' => APPS_PATH .'/../logs/SkrillPay.log',
        'log.LogLevel' => 'INFO', // PLEASE USE `INFO` LEVEL FOR LOGGING IN LIVE ENVIRONMENTS
        'cache.enabled' => false,
        'http.CURLOPT_CONNECTTIMEOUT' => 30
    )
);

$payload = json_encode($_POST);

$hook = new Webhook();
$hook->setPayload($payload);

try{
    if($hook->verify($skrill)){
        $payload = $hook->getVerifyWebhookSignature()->getWebhookResponse();
        //业务处理

    }
}catch (Exception $e){

}
bash
composer