PHP code example of dinhdjj / laravel-thesieure

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

    

dinhdjj / laravel-thesieure example snippets


// config for dinhdjj/laravel-thesieure
return [
    'domain' => env('THESIEURE_DOMAIN', 'thesieure.com'),
    'partner_id' => env('THESIEURE_PARTNER_ID'),
    'partner_key' => env('THESIEURE_PARTNER_KEY'),

    /**
     * The callback will be call when thesieure callback to server.
     */
    'callback' => [
        'route' => [
            'name' => 'thesieure.callback',
            'uri' => 'api/thesieure/callback',
            'middleware' => [
                'api',
            ],
            'method' => 'post',
        ],
    ],

    /**
     * Used when fetch card types from thesieure server.
     */
    'fetch_card_types' => [
        'cache' => [
            'enabled' => true,
            'key' => 'thesieure.card_types',
            'ttl' => 60 * 5, // 5 minutes,
            'store' => null, // used default store
        ],
    ],
];

// app/Providers/AppServiceProvider.php

public function boot()
{
    \Thesieure::onCallback(function(Dinhdjj\Thesieure\Types\ApprovedCard $card){
        // Each property of $card equivalent to thesieure's attributes read more on `thesieure`
        // Besides, $card also have some helper methods

        if($card->isApproving()){
            // Do something
        }

        if($card->isSuccess()){
            $receivedValue = $card->getReceivedValue();
            $realFaceValue = $card->getRealFaceValue();

            // Do something
        }

        if($card->isError()){
            // Do something
        }
    });
}

    \Thesieure::approveCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything');
    \Thesieure::updateApprovedCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything');
bash
php artisan vendor:publish --tag="thesieure-config"