PHPackages                             webribs/safepay-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. webribs/safepay-laravel

ActiveLibrary

webribs/safepay-laravel
=======================

Safepay payment gateway integration with Laravel

015.7k↓35%PHP

Since Oct 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rizwansaleem70/safepay-laravel)[ Packagist](https://packagist.org/packages/webribs/safepay-laravel)[ RSS](/packages/webribs-safepay-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

safepay-laravel
===============

[](#safepay-laravel)

Safepay Laravel Payment Gateway Integration

`composer require webribs/safepay-laravel`

Add provider in app.php

`Webribs\Safepay\SafepayProvider`

Add alias

`'SafePay' => Webribs\Safepay\SafepayFacade::class`

### Publish the migration file.

[](#publish-the-migration-file)

`php artisan migrate`

It will create a table named "payment\_logs".

### Publish the configuration file

[](#publish-the-configuration-file)

`php artisan vendor:publish`A file (safepay.php) will be placed in config folder.

```
return [
    "environment"  => "sandbox", //use 'production' for live payments
    "api_key" => "",
    'redirect_url' => "http://localhost:8000/success",
    'cancel_url' => "http://localhost:8000/payment-cancel",
    'currency' => "PKR",
    'webhook_secret_key' => "",
    'order_class' => Order::class
];

```

To make payment, you need to pass order\_id and total amount in process\_payment()

```
use Webribs\Safepay\Safepay;

$safepay = new Safepay;
$link = $safepay->process_payment($order_id, $cart_total);

```

In response, it will return a redirect link. Simply redirect the user

```
if($link['result'] == 'success')
    return redirect($link['redirect']);

```

When payment is done on safepay, you will be redirected to redirect\_url that you passed in config file.

Safepay will post this data in redirect url.

```
array (
  'order_id' => '1',
  'sig' => '215557faae130d4b65dbd30b1838b816bb03c08531d861fd1215a836aaab5188',
  'reference' => '532860',
  'tracker' => 'track_93281536-3687-44a6-ac2b-4d015f98ef46',
  'token' => 'trans_eeedfc06-21d6-4c67-b1bc-941a7ac73e10',
)

```

### Now create a route in web.php file

[](#now-create-a-route-in-webphp-file)

```
Route::post('success', 'Front\HomeController@storePaymentLog');
Route::get('payment-success/{sig}', 'Front\HomeController@viewPaymentSuccessPage')->name('payment_success');
Route::get('payment-cancel', 'Front\HomeController@viewCancelPaymentPage');

```

In VerifyCsrfToken.php middleware, add the following code

```
protected \$except = [
  'success'
];

```

In storePaymentLog method you need to validate the signature. If signature is validated then store the payment log and update the order status.

```
public function storePaymentLog(Request $request)
{
    $data = $request->input();
    $safepay = new Safepay;

    if ($safepay->validate_signature($data['tracker'], $data['sig']) === false) {
        return redirect()->route('checkout.index')->with(['error' => 'Payment Failed']);
    }

    PaymentLog::create([
        'order_id' => $data['order_id'],
        'reference_code' => $data['reference'],
        'tracker' => $data['tracker'],
        'signature' => $data['sig'],
    ]);

    //update order status
    $order = Order::find($data['order_id']);
    $order->order_status_id = 1; //Paid
    $order->save();

    event(new OrderCreateEvent($order));

    Cart::destroy();

    return redirect()->route('payment_success', $data['sig']);
}

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1a63cc6b5a2e446a73d9f85219ce820c0ba5b091590a0adb15851b6426a6574?d=identicon)[rizwansaleem](/maintainers/rizwansaleem)

---

Top Contributors

[![rizwansaleem70](https://avatars.githubusercontent.com/u/10451770?v=4)](https://github.com/rizwansaleem70 "rizwansaleem70 (25 commits)")

### Embed Badge

![Health badge](/badges/webribs-safepay-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/webribs-safepay-laravel/health.svg)](https://phpackages.com/packages/webribs-safepay-laravel)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
