PHPackages                             matiullah31/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. [Payment Processing](/categories/payments)
4. /
5. matiullah31/safepay-laravel

ActiveLibrary[Payment Processing](/categories/payments)

matiullah31/safepay-laravel
===========================

Safepay payment gateway integration with Laravel

v1.0(3y ago)0143MITPHP

Since Aug 6Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

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

[](#safepay-laravel)

Safepay Laravel Payment Gateway Integration

`composer require matiullah31/safepay-laravel`

Add provider in app.php

`Priceoye\Safepay\SafepayProvider`

Add alias

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

### Publish the configuration file

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

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

```

return [
    "environment"  => env("SAFEPAY_ENV",'sandbox'), //use 'production' for live payments
    "api_key" => env("SAFEPAY_API_KEY",''),
    'redirect_url' => env("SAFEPAY_SUCCESS_URL",''),
    'cancel_url' => env("SAFEPAY_CANCEL_URL",''),
    'currency' => "PKR",
    'webhook_secret_key' => env("SAFEPAY_SECRET",'')
    'webhook_shared_secret_key' => env("SAFEPAY_SHARED_SECRET",''),
];

```

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

```
use Priceoye\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('payment-success', 'SafepayController@paymentCompleted');
Route::get('order-completed/{sig}', 'OrderController@orderCompleted')->name('orderCompleted');
Route::get('payment-cancel', 'OrderController@orderCancelled');

```

In VerifyCsrfToken.php middleware, add the following code

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

```

On payment-success route and paymentCompleted function.

```
public function paymentCompleted(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']);
    }

    return redirect(url('order-completed/'.$data['sig']));

}

```

### Now to add Webhook and verify it add route in api.php file

[](#now-to-add-webhook-and-verify-it-add-route-in-apiphp-file)

```

Route::post('api/safepayNotification', 'SafepayApiController@safepayNotification');

```

Now to verify the web hook request

```

public function safepayNotification(Request $request)
{
    $data = $request->all();

    $safepay = new Safepay;

    $x_sfpy_signature = $request->header('x-sfpy-signature');

    if ($safepay->verifyWebhook($data, $x_sfpy_signature) === false) {

        //Web Hook verification failed

    }

}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1375d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97bc65cbc122877e6b20e051eb716b69c0383bb7986de130762dad9aa8f6894d?d=identicon)[matiullah31](/maintainers/matiullah31)

---

Top Contributors

[![matiullah31](https://avatars.githubusercontent.com/u/9604691?v=4)](https://github.com/matiullah31 "matiullah31 (1 commits)")

---

Tags

laravellaravel-packagesafepaylaravel payment gatewaysafepay

### Embed Badge

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

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

###  Alternatives

[shetabit/payment

Laravel Payment Gateway Integration Package

944330.1k5](/packages/shetabit-payment)[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)

PHPackages © 2026

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