amjad-ghzlan/paymera-payment-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amjad-ghzlan/paymera-payment-laravel

Composer 安装命令:

composer require amjad-ghzlan/paymera-payment-laravel

包简介

Laravel package for Paymera eGate payment gateway

README 文档

README

PHP Laravel Packagist License

Laravel package for integrating with the Paymera eGate payment gateway API.

Requirements

  • PHP ^8.1
  • Laravel ^10.0 | ^11.0 | ^12.0

Installation

composer require amjad-gh/paymera-payment-laravel

The service provider and facade are auto-discovered by Laravel.

Publish the config file

php artisan vendor:publish --tag=paymera-config

Configuration

Add the following variables to your .env file:

PAYMERA_BASE_URL=https://egate-t.paymera.cc   # test environment
# PAYMERA_BASE_URL=https://egate.paymera.cc   # production environment

PAYMERA_USERNAME=your-username
PAYMERA_PASSWORD=your-password
PAYMERA_TERMINAL_ID=your-terminal-id
PAYMERA_LANG=en

Security: credentials are sent via HTTP Basic Auth on the server side only and are never exposed to the client.

The published config file (config/paymera.php) contains:

return [
    'base_url'    => env('PAYMERA_BASE_URL', 'https://egate-t.paymera.cc'),
    'username'    => env('PAYMERA_USERNAME'),
    'password'    => env('PAYMERA_PASSWORD'),
    'terminal_id' => env('PAYMERA_TERMINAL_ID'),
    'lang'        => env('PAYMERA_LANG', 'en'),
];

Usage

Create a Payment

use Casper\Paymera\Facades\Paymera;
use Casper\Paymera\DTOs\CreatePaymentRequest;

$result = Paymera::createPayment(new CreatePaymentRequest(
    amount:      5000,                                             // amount in smallest currency unit
    callbackURL: 'https://yourapp.com/orders/1234/payment/return', // see note below
    triggerURL:  'https://yourapp.com/payment/webhook',            // server-to-server notification
    terminalId:  config('paymera.terminal_id'),
    lang:        config('paymera.lang'),
    notes:       'Order #1234',                                    // optional
));

// $result->paymentId  — unique payment identifier
// $result->redirectUrl — redirect the user here to complete payment

return redirect($result->redirectUrl);

callbackURL is the URL the gateway redirects the user to when they click Cancel or Close after the payment flow. Include the merchant order identifier in the URL so your landing page can identify which order is returning (e.g. /orders/1234/payment/return).

Get Payment Status

use Casper\Paymera\Facades\Paymera;

$status = Paymera::getPaymentStatus($paymentId);

if ($status->isAccepted()) {
    // payment succeeded
}

if ($status->isPending()) {
    // still waiting
}

if ($status->isFailed()) {
    // payment failed
}

if ($status->isCanceled()) {
    // payment was canceled
}

// Raw enum value:  $status->status  (PaymentStatus enum)
// Other fields:    $status->rrn, $status->amount, $status->terminalId,
//                  $status->creationTimestamp, $status->notes

Cancel a Payment

use Casper\Paymera\Facades\Paymera;

Paymera::cancelPayment($paymentId);

API Environments

Environment Base URL
Test https://egate-t.paymera.cc
Production https://egate.paymera.cc

Switch environments by changing PAYMERA_BASE_URL in your .env.

DTOs

CreatePaymentRequest

Parameter Type Required Default Description
amount int Amount in smallest currency unit
callbackURL string URL the gateway redirects the user to when they click Cancel or Close after payment. Should include the merchant order identifier so the landing page can determine which order it belongs to (e.g. https://yourapp.com/orders/1234/payment/return)
triggerURL string Server-to-server webhook URL
terminalId string Your terminal ID
lang string Language code (e.g. en)
notes string|null null Optional payment notes
savedCards int 0 Enable saved cards (1 = yes)
appUser string|null null Optional app user identifier

CreatePaymentResult

Property Type Description
paymentId string Unique payment ID
redirectUrl string URL to redirect the user to

PaymentStatusResult

Property Type Description
status PaymentStatus Enum: Pending, Accepted, Failed, Canceled
rrn string|null Reference retrieval number
amount int Payment amount
terminalId string|null Terminal ID
creationTimestamp string|null ISO 8601 creation time
notes string|null Payment notes

PaymentStatus Enum

use Casper\Paymera\Enums\PaymentStatus;

PaymentStatus::Pending  // 'P'
PaymentStatus::Accepted // 'A'
PaymentStatus::Failed   // 'F'
PaymentStatus::Canceled // 'C'

Exception Handling

All exceptions extend PaymeraException which extends RuntimeException.

use Casper\Paymera\Exceptions\PaymeraException;
use Casper\Paymera\Exceptions\UnauthorizedException;
use Casper\Paymera\Exceptions\PaymentFailedException;

try {
    $result = Paymera::createPayment($request);
} catch (UnauthorizedException $e) {
    // Invalid credentials — error code 1
} catch (PaymentFailedException $e) {
    // Payment failed — error code 100
} catch (PaymeraException $e) {
    // Any other Paymera error
    $e->getErrorCode();  // raw error code from API
    $e->getMessage();    // error message from API
}

Testing

The package ships with a Pest test suite. From the package root:

composer install
./vendor/bin/pest tests/

In your own application tests, use Http::fake() to mock the gateway:

use Illuminate\Support\Facades\Http;

Http::fake([
    '*/api/create-payment' => Http::response([
        'ErrorCode'    => 0,
        'ErrorMessage' => 'Success',
        'Data'         => [
            'paymentId' => 'pay_test123',
            'url'       => 'https://egate-t.paymera.cc/pay/pay_test123',
        ],
    ]),
]);

License

MIT

amjad-ghzlan/paymera-payment-laravel 适用场景与选型建议

amjad-ghzlan/paymera-payment-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 amjad-ghzlan/paymera-payment-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amjad-ghzlan/paymera-payment-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 amjad-ghzlan/paymera-payment-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-04