PHPackages                             rmazarei/sama-laravel-payment-rmazarei - 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. rmazarei/sama-laravel-payment-rmazarei

ActiveLibrary[Payment Processing](/categories/payments)

rmazarei/sama-laravel-payment-rmazarei
======================================

Sama gateway library for Laravel. Some test chnages

07PHP

Since Jul 17Pushed 2y agoCompare

[ Source](https://github.com/rmazarei/sama-laravel-payment-rmazarei)[ Packagist](https://packagist.org/packages/rmazarei/sama-laravel-payment-rmazarei)[ RSS](/packages/rmazarei-sama-laravel-payment-rmazarei/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

درگاه پرداخت سما | Sama Payment Gateway
=======================================

[](#درگاه-پرداخت-سما--sama-payment-gateway)

Sama Gateway library for Laravel based on Sama API

کتابخانه درگاه پرداخت سما برای لاراول براساس ای‌پی‌آی سما

روش نصب - Installation
----------------------

[](#روش-نصب---installation)

Use composer to install this package

برای نصب و استفاده از این پکیج می توانید از کامپوزر استفاده کنید

```
composer require sama-ir/sama-laravel-payment
```

تنظیمات - Configuration
-----------------------

[](#تنظیمات---configuration)

Add your token to .env file

توکن خود را اضافه کنید

```
SAMA_GATEWAY_TOKEN=abcd
```

You can also set token at runtime.

امکان تعیین توکن در حین اجرا نیز وجود دارد که در ادامه توضیح داده خواهد شد.

روش استفاده | How to use
------------------------

[](#روش-استفاده--how-to-use)

### ارسال مشتری به درگاه پرداخت | Send customer to payment gateway

[](#ارسال-مشتری-به-درگاه-پرداخت--send-customer-to-payment-gateway)

```
    $response = sama()
                // ->token('abcd') // تعیین توکن در حین اجرا - اختیاری
                ->amount(10000) // مبلغ تراکنش
                ->request()
                ->clientId('0a1dca49-96bb-4318-a7cb-ebf2a6281003') // مقدار شناسه تراکنش در فروشگاه (باید یکتا باشد)
                ->callbackUrl('http://localhost:8000/api/payment_callback') // آدرس برگشت پس از پرداخت
                ->mobile('09123456789') // شماره موبایل مشتری - اختیاری
                ->send();

    if (!$response->success()) {
        return [
            $response->error()->code(),
            $response->error()->detail(),
            $response->error()->message(),
            $response->error()->extra()
        ];
    }

    // ذخیره اطلاعات در دیتابیس
    // ...
    // هدایت مشتری به درگاه پرداخت

    return $response->redirect();
```

### بررسی وضعیت تراکنش | Verify payment status

[](#بررسی-وضعیت-تراکنش--verify-payment-status)

```
    $price = request()->post('price'); // دریافت پارامتر ارسال شده توسط سما
    $requestId = request()->post('request_id'); // دریافت پارامتر ارسال شده توسط سما
    $resultCode = request()->post('result_code'); // دریافت پارامتر ارسال شده توسط سما
    $processId = request()->post('process_id'); // دریافت پارامتر ارسال شده توسط سما

    $savedPriceInDb = 10000;
    $clientId = '0a1dca49-96bb-4318-a7cb-ebf2a6281003';

    if ($resultCode != 0 || $price != $savedPriceInDb) {
        // Payment was not successful or someone tampered with the data
        return ["status" => "failed", "message" => "پرداخت ناموفق"];
    }

    // Successful payment, lets verify with Sama Gateway
    $response = sama()
                // ->token('abcd') // تعیین توکن در حین اجرا - اختیاری
                ->verification()
                ->requestId($requestId)
                ->clientId($clientId)
                ->send();

    if (!$response->success() || $response->isPaid() === false) {
        // $response->error()->code(),
        // $response->error()->detail(),
        return ["status" => "failed", "message" => "پرداخت ناموفق"];
    }
    if($savedPriceInDb != $response->$price) {
        // Someone tampered with the data, prices do not match
        return ["status" => "failed", "message" => "پرداخت ناموفق"];
    }

    // پرداخت موفقیت آمیز بود

    echo $response->isPaid(); // === true means successful payment
    echo $response->paymentId();
    echo $response->requestId();

    // دریافت شماره پیگیری تراکنش و انجام امور مربوط به دیتابیس

    // Save referenceNumber and transactionCode in the database
    echo $response->referenceNumber();
    echo $response->transactionCode();

    return ["status" => "ok", "message" => "پرداخت موفق"];
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 77.8% 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/5c14aa17bf14604333511cf1b1b7a4d5a45e64103179132660094ce95bb48a44?d=identicon)[rmazarei](/maintainers/rmazarei)

---

Top Contributors

[![asedmammad](https://avatars.githubusercontent.com/u/26073142?v=4)](https://github.com/asedmammad "asedmammad (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![mosi2142](https://avatars.githubusercontent.com/u/31867394?v=4)](https://github.com/mosi2142 "mosi2142 (1 commits)")

### Embed Badge

![Health badge](/badges/rmazarei-sama-laravel-payment-rmazarei/health.svg)

```
[![Health](https://phpackages.com/badges/rmazarei-sama-laravel-payment-rmazarei/health.svg)](https://phpackages.com/packages/rmazarei-sama-laravel-payment-rmazarei)
```

###  Alternatives

[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)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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