PHP code example of smronju / laravel-sslcommerz

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

    

smronju / laravel-sslcommerz example snippets


use Smronju\Sslcommerz\Facades\Sslcommerz;

$response = Sslcommerz::setOrder($amount, $invoiceId, $productName)
    ->setCustomer($name, $email, $phone)
    ->makePayment();

if ($response->success()) {
    return redirect($response->gatewayPageURL());
}

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

if ($isValid) {
    // Save to database, update status, etc.
}

Route::post('/sslcommerz/success', [SslcommerzController::class, 'success'])->name('sslcommerz.success');
Route::post('/sslcommerz/failure', [SslcommerzController::class, 'failure'])->name('sslcommerz.failure');

// Request a refund
$refund = Sslcommerz::refundPayment($bankTranId, $amount, "Customer requested refund");

// Check refund status
$status = Sslcommerz::checkRefundStatus($refundRefId);
bash
php artisan laravel-sslcommerz:install