PHP code example of raziul / sslcommerz-laravel

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

    

raziul / sslcommerz-laravel example snippets


use \Raziul\Sslcommerz\Facades\Sslcommerz;

$response = Sslcommerz::setOrder(
        $amount,
        $invoiceId,
        $productName,
    )->setCustomer(
        $customerName,
        $customerEmail,
        $customerPhone,
    )->setShippingInfo(
        $itemsQuantity,
        $address,
    )->makePayment();

if ($response->success()) {
    // payment initiated, redirect to payment page
    return redirect($response->gatewayPageURL());
} else {
    // Handle payment failure
}

use \Raziul\Sslcommerz\Facades\Sslcommerz;

$isValid = Sslcommerz::validatePayment(
    request()->all(),
    $transactionId,
    $amount,
);

if ($isValid) {
    // Payment is valid
} else {
    // Payment is invalid
}
bash
php artisan sslcommerz:install"