PHP code example of plisio / plisio-sdk-laravel

1. Go to this page and download the library: Download plisio/plisio-sdk-laravel 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/ */

    

plisio / plisio-sdk-laravel example snippets


use Plisio\PlisioSdkLaravel\Payment;

//Initializing payment gateway with api_key in app/config .
$plisioGateway = new Payment(config('plisio.api_key'));

$shopInfo = $plisioGateway->getShopInfo();

$btcWalletBalance = $plisioGateway->getBalances('BTC');

$currencies = $plisioGateway->getCurrencies('CAD');

//Data about the client and his order, which must be inserted into the invoice.
$params = [...];

$data = array(
    'order_name' => 'Order #' . $params['invoiceid'], //Merchant internal order name.
    'order_number' => $params['invoiceid'],           //Merchant internal order number. Must be a unique number in your store for each new store`s order.
    'description' => $params['order_description'],    //Optional order description.
    'source_amount' => number_format($params['amount'], 8, '.', ''),  //Invoice total float value in fiat currency.
    'source_currency' => $params['currency'],         //Fiat currency code. For example: USD, BRL, CAD etc.
    'cancel_url' => 'https://examplestore.com/failedOrder.php?id=' . $params['invoiceid'],  //User will be redirected to this link in a case of invoice payment failure.
    'callback_url' => 'https://examplestore.com/callback.php',       //The link to which you will receive a notification about a change in the status of the order.
    'success_url' => 'https://examplestore.com/successOrder.php?id=' . $params['invoiceid'],  //User will be redirected to this link in a case of invoice payment success.
    'email' => $params['clientdetails']['email'],     //User's email. If not specified user will be asked to enter his email on the invoice page.
    'plugin' => 'laravelSdk',                         //Payment gateway origin. This value will help Plisio to analyse any problem occurred with SDK functionality.
    'version' => '1.0.0'                              //Consider updating this setting every time you update the functionality related to this sdk.
    );
    
    //Create invoice and put response to the $response variable.
    $response = $plisioGateway->createTransaction($data);
    
    //Check the response and, depending on the result, redirect the user to Plisio for further payment or return to the checkout page with an error.
    if ($response && $response['status'] !== 'error' && !empty($response['data'])) {
        redirect($response['data']['invoice_url']);
        clearCart();
    } else {
        $errorMessage = implode(',', json_decode($response['data']['message'], true));
        redirectToCheckout();
    }

$shopInfo = $plisioGateway->getShopInfo();
$isWhiteLabel = $shopInfo['data']['white_label'];

//callback.php
$callbackData = $_POST;

if ($plisioGateway->verifyCallbackData($callbackData)) {
    //Change invoice status, notify user etc.
} else {
    //HTTP 403 error. Callback data is not valid!
}
bash
php artisan vendor:publish --provider="Plisio\PlisioSdkLaravel\Providers\PlisioProvider"