PHP code example of sam-asif / sslcommerz

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

    

sam-asif / sslcommerz example snippets




return [
    // ...
    'providers' => [
        SamAsif\Sslcommerz\SSLCommerzServiceProvider::class,
        // ...
    ],
    // ...
];



use SamAsif\Sslcommerz\Http\Controllers\SamSSL;


class OrderController extends Controller
{

 public function Order(Request $request)
    {

    	// .......

    	$sslc = new SamSSL();
        $payment_options = $sslc->index($request, 'hosted');



        if (!is_array($payment_options)) {
            print_r($payment_options);
            $payment_options = array();
        }

    }

}




use SamAsif\Sslcommerz\Http\Controllers\SamSSL;


class OrderController extends Controller
{

 public function Order(Request $request)
    {

    	$post_data = array();
        $post_data['total_amount'] = '10'; # You cant not pay less than 10
        $post_data['currency'] = "BDT";
        $post_data['tran_id'] = uniqid(); // tran_id must be unique
        // .......
    	

    	// Initialize SSlcommerz gateway

    	$sslc = new SamSSL();
        $payment_options = $sslc->index($post_data, 'hosted');



        if (!is_array($payment_options)) {
            print_r($payment_options);
            $payment_options = array();
        }

    }


    // For received return  value

    public function return(Request $request){
      return $request->all();
    }

}


php artisan vendor:publish