PHP code example of code4mk / lara-sslcommerz

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

    

code4mk / lara-sslcommerz example snippets


Code4mk\Sslcommerz\SslcommerzServiceProvider::class

use SslPayment;

$data = SslPayment::tnx(2)
          ->customer('kamal212')
          ->amount(100)
          ->emi(4,5,1)
          ->getRedirectUrl();

if( $data->failedreason == "") {
    $link = $data->GatewayPageURL;
    return response()->json($link);
}else{
  // your code
    return response()->json($data->failedreason);
}

use SslPayment;
$data = SslPayment::verify(request());
// return response()->json($data);
if ($data->status == 'VALID') {
    // your business logic
 }

/* you can get success objects which triggers by sslcomerz.
  you can
*/
Route::post('ipn',function(){
  return response()->json(request());
})


namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/success',
        '/ipn'
    ];
}

bash
php artisan vendor:publish --provider="Code4mk\Sslcommerz\SslcommerzServiceProvider" --tag=config