PHPackages                             rostam-sodagari/laravel-yekpay - 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. rostam-sodagari/laravel-yekpay

ActiveLibrary[Payment Processing](/categories/payments)

rostam-sodagari/laravel-yekpay
==============================

Laravel wrapper for YekPay payment API (request/start/verify).

v1.0.0(4mo ago)08MITPHPPHP ^8.1CI passing

Since Jan 8Pushed 3mo agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel YekPay
==============

[](#laravel-yekpay)

A clean, production-ready Laravel package for integrating with the **YekPay payment gateway**.
It wraps the full **request → redirect → verify** payment lifecycle using **typed DTOs** and **PHP enums**, with facade Laravel support.

[Read Official Document](https://docs.yekpay.com)
-------------------------------------------------

[](#read-official-document)

Features
--------

[](#features)

- Full YekPay payment flow (Request / Start / Verify)
- Strong typing via DTOs and PHP 8.1+ enums
- Currency codes as enum (no magic numbers)
- Sandbox &amp; production support
- Configurable endpoints and timeouts
- Testable architecture (Guzzle + Testbench)
- Laravel 10 / 11 compatible

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x or 11.x

---

Installation
------------

[](#installation)

Install via Composer:

```
composer require rostam-sodagari/laravel-yekpay

```

Publish the configuration file:

```
php artisan vendor:publish --tag=yekpay-config

```

---

Configuration
-------------

[](#configuration)

Set your credentials in `.env`:
-------------------------------

[](#set-your-credentials-in-env)

```
YEKPAY_MERCHANT_ID=your-merchant-id
YEKPAY_SANDBOX=true

```

---

Main config file: `config/yekpay.php`

```
return [
    'merchant_id' => env('YEKPAY_MERCHANT_ID'),

    'sandbox' => env('YEKPAY_SANDBOX', false),

    'timeouts' => [
        'connect' => 5,
        'request' => 20,
    ],

    'endpoints' => [
        'production' => [
            'request' => 'https://gate.ypsapi.com/api/payment/request',
            'start'   => 'https://gate.ypsapi.com/api/payment/start/{AUTHORITY}',
            'verify'  => 'https://gate.ypsapi.com/api/payment/verify',
        ],
        'sandbox' => [
            'request' => 'https://api.ypsapi.com/api/sandbox/request',
            'start'   => 'https://api.ypsapi.com/api/sandbox/payment/{AUTHORITY}',
            'verify'  => 'https://api.ypsapi.com/api/sandbox/verify',
        ],
    ],
];

```

---

Payment Flow Overview
---------------------

[](#payment-flow-overview)

[![Payment Flow](https://camo.githubusercontent.com/36d7c3e0cb9ea1a7caf9797f815c58136981238f16295065f31c4fa034de1ce9/68747470733a2f2f646f63732e79656b7061792e636f6d2f696d616765732f636f6e74656e742f6f766572766965772d63633565373166392e706e67)](https://camo.githubusercontent.com/36d7c3e0cb9ea1a7caf9797f815c58136981238f16295065f31c4fa034de1ce9/68747470733a2f2f646f63732e79656b7061792e636f6d2f696d616765732f636f6e74656e742f6f766572766965772d63633565373166392e706e67)YekPay uses a three-step payment process:

1. Request Payment → Receive Authority
2. Redirect User → Gateway payment page
3. Verify Payment → Confirm transaction

This package mirrors that flow explicitly.

---

Usage
-----

[](#usage)

### Request Payment

[](#request-payment)

```
use RostamSodagari\YekPay\Enums\Currency;
use RostamSodagari\YekPay\Facade\Yekpay;
use RostamSodagari\YekPay\DTO\RequestPaymentData;

$result = YekPay::request(new RequestPaymentData(
        fromCurrency: Currency::EUR,
        toCurrency: Currency::EUR,
        email: 'user@example.com',
        mobile: '+4474940000000',
        firstName: 'John',
        lastName: 'Doe',
        address: 'Address Here',
        postalCode: 'Postal Code',
        country: "United Kingdomm",
        city: "London",
        callback: 'http://verify-callback-here',
        orderNumber: 'unique-order-number',
        amount: 1000,
        description: 'Order #1001',
    ));

if (! $result->ok() || ! $result->authority) {
    abort(400, $result->getDescription());
}

```

---

### Redirect User to Gateway

[](#redirect-user-to-gateway)

```
return redirect()->away(
    Yekpay::startUrl($result->getAuthority())
);

```

---

### Verify Payment (Callback)

[](#verify-payment-callback)

```
use Illuminate\Http\Request;
use RostamSodagari\YekPay\Facade\Yekpay;

public function callback(Request $request)
{
    $authority = (string) $request->input('Authority');

        if ($authority === '') {
            abort(400, 'Missing Authority');
        }

        $verify = Yekpay::verify($authority);

        if (! $verify->ok()) {
            abort(400, $verify->description);
        }

        return response()->json([
            'status'    => 'paid',
            'reference' => $verify->reference,
            'order'     => $verify->orderNo,
            'amount'    => $verify->amount,
        ]);
}

```

---

Test Cards (Sandbox Mode)
-------------------------

[](#test-cards-sandbox-mode)

The following card details are **sandbox-only test cards** provided for integration testing with the [Yekpay](https://yekpay.com) payment gateway.

⚠️ **Important**

- These cards work **only in sandbox mode**
- They are **not real cards**
- Do **not** use them in production

Card NameCard NumberExpiration DateCVCExpected ResultJohn Doe5269 5522 3333 44452028/12000Unsuccessful transactionDavid Doe4022 7711 2222 33342028/12000Successful transaction---

Currency Enum
-------------

[](#currency-enum)

All supported currencies are defined as a PHP enum:

```
use RostamSodagari\YekPay\Enums\Currency;

Currency::EUR; // 978
Currency::IRR; // 364

```

Note on TRY currency:
YekPay documentation contains conflicting TRY codes. This package uses the official appendix value by default, but you should confirm via sandbox before production use.

---

Error Handling Philosophy
-------------------------

[](#error-handling-philosophy)

- Gateway responses are never trusted blindly
- ok() checks numeric result codes
- Raw gateway payload is preserved internally for logging

---

Testing
-------

[](#testing)

This package is fully testable and ships with:

- Orchestra Testbench
- Guzzle MockHandler
- No real HTTP calls

---

Security Best Practices
-----------------------

[](#security-best-practices)

- Always verify payment before marking orders as paid
- Never trust callback parameters alone
- Persist gateway Reference for audit trails
- Enable sandbox during development

---

License
-------

[](#license)

MIT © Rostam Sodagari

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance80

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54d7d2adea2117eeeb487f9f33677401610fb81601304633bc1a54ea3a91888c?d=identicon)[rostam-sodagari](/maintainers/rostam-sodagari)

---

Top Contributors

[![rostam-sodagari](https://avatars.githubusercontent.com/u/19219687?v=4)](https://github.com/rostam-sodagari "rostam-sodagari (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rostam-sodagari-laravel-yekpay/health.svg)

```
[![Health](https://phpackages.com/badges/rostam-sodagari-laravel-yekpay/health.svg)](https://phpackages.com/packages/rostam-sodagari-laravel-yekpay)
```

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

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