dinhdjj/laravel-thesieure

This package is abandoned and no longer maintained. No replacement package was suggested.

Provide a helper interface to communicate with thesieure easily

v1.2.0 2022-05-21 13:23 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

You can install the package via composer:

composer require dinhdjj/laravel-thesieure

You can publish the config file with:

php artisan vendor:publish --tag="thesieure-config"

This is the contents of the published config file:

// 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
        ],
    ],
];

Usage

Firstly, you should register logic to handle the callback from thesieure.

// 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
        }
    });
}

Next, you should register the callback in thesieure. By default, the callback route ispost:/api/thesieure/callback.

Finally, when you need to send a card to thesieure approve:

    \Thesieure::approveCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything');
    \Thesieure::updateApprovedCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything');

When thesieure response the result, error or when you call approveCard, updateApprovedCard method, closure you transfer to \Thesieure::onCallback will be invoked. All things you need to do is register logic in \Thesieure::onCallback.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.