PHP code example of dgvai / laravel-sslcommerz

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

    

dgvai / laravel-sslcommerz example snippets


    Route::post('sslcommerz/success','PaymentController@success')->name('payment.success');
    Route::post('sslcommerz/failure','PaymentController@failure')->name('failure');
    Route::post('sslcommerz/cancel','PaymentController@cancel')->name('cancel');
    Route::post('sslcommerz/ipn','PaymentController@ipn')->name('payment.ipn');

    protected $except = [
        'sslcommerz/*'
    ];


    public function refund($bankID)
    {
        /** 
         * SSLCommerz::refund($bank_trans_id, $amount [,$reason])
         */

        $refund = SSLCommerz::refund($bankID,$refund_amount);

        if($refund->status)
        {
            /**
             * States:
             * success : Refund request is initiated successfully
             * failed : Refund request is failed to initiate
             * processing : The refund has been initiated already
            */

            $state  = $refund->refund_state;

            /**
             * RefID will be used for post-refund status checking
            */

            $refID  = $refund->ref_id;

            /**
             *  To get all the outputs
            */

            dd($refund->output);
        }
        else 
        {
            return $refund->message;
        }
    }

    public function check_refund_status($refID)
    {
        $refund = SSLCommerz::query_refund($refID);
	
        if($refund->status)
        {
            /**
             * States:
             * refunded : Refund request has been proceeded successfully
             * processing : Refund request is under processing
             * cancelled : Refund request has been proceeded successfully
            */

            $state  = $refund->refund_state;

            /**
             * RefID will be used for post-refund status checking
            */

            $refID  = $refund->ref_id;

            /**
             *  To get all the outputs
            */

            dd($refund->output);
        }
        else 
        {
            return $refund->message;
        }
    }

 

    public function get_transaction_status($trxID)
    {
        $query = SSLCommerz::query_transaction($trxID);
	
        if($query->status)
        {
            dd($query->output);
        }
        else 
        {
            $query->message;
        }
    }

bash
    php artisan vendor:publish --tag=sslc-config
bash
    php artisan config:cache