承接 nasimic/payriff 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nasimic/payriff

Composer 安装命令:

composer require nasimic/payriff

包简介

Payriff

README 文档

README

This repo can be used as to implement Payriff Payments (V3) to Laravel application. Supporting PHP 8.1+ versions.

Installation

composer require nasimic/payriff

Configuration

Normally config file will be published automatically. In case of manual publish:

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

Add your credentials to .env file

PAYRIFF_SECRET_KEY=your secret here

Usage

PayriffServiceProvider generates PayriffClient to inject directly to a constructor or to a method. And it is highly recommended to chose Dependency Injection over Facades.

With constructor:

use Nasimic\Payriff\PayriffClient;

public function __construct(
    private readonly PayriffClient $payriffClient,
) {
}

With method

use Nasimic\Payriff\PayriffClient;

public function pay(PayriffClient $payriffClient) {
...
}

Alternatively, you could get PayriffClient instance from container or bind with PayriffClientInterface on service provider.

Examples

Create order

You will play with Data classes (DTO) to send and get populated data. Good for validation purposes and valid states.

use Nasimic\Payriff\PayriffClient;
use Nasimic\Payriff\Data\Request\CreateOrderRequest;

...

public function createPaymentUrl(Order $order) {
    $orderRequestDto = new CreateOrderRequest(
        amount: $order->price,
        callbackUrl: CUSTOM_CALLBACK_URL // optional
    );

    $orderResponseDto = $this->payriffClient->createOrder($orderRequestDto);
    
    // You will need orderId to retrieve order info later.
    // Save orderId. This represents payment of your order on Payriff.
    // Let's say save it on DB column.
    $order->update(['payriff_payment_id' => $orderResponseDto->orderId]);
    
    return $orderResponseDto->paymentUrl;
}

You will get CreateOrderResponse class with populated data. Save orderId and redirect user to the Payment URL.

If the callbackUrl are left blank, then user will be redirected to proper Payriff pages (Success, Cancel, Decline)

On successful transaction, Payriff will POST transaction data to callbackURL. However, it is recommended to handle payment callback with Get Order (after Payriff redirecting to callbackUrl). Also consider updating statuses of abandoned Payments.

More opinionated Create order request:

$orderRequestDto = new CreateOrderRequest(
    amount: 75,
    callbackUrl: CUSTOM_CALLBACK_URL,
    currency: "USD", // default is AZN
    language: "RU", // default is AZ
    description: "Test order",
    cardSave: true,
    operation: "PRE_AUTH", // default is PURCHASE
    installment: [
        "type" => "TAMKART", 
        "period" => "PERIOD_2"
    ]
);
}

Get Order

You can retrieve order with multiple functions depending on purpose

public function handleCallback(Order $order) {

    // To get all information about order (returns OrderInformationResponse)
    $this->payriffClient->getOrderInformation($order->payriff_payment_id);
    
    // To get only payment status (returns string)
    $this->payriffClient->getOrderStatus($order->payriff_payment_id);
    
    // To check order is paid (returns bool)
    $this->payriffClient->isOrderPaid($order->payriff_payment_id);
    
    ...
}

OrderInformationResponse is Data object and has these properties populated:

string $orderId,
float $amount,
string $currencyType,
?string $merchantName,
string $operationType,
string $paymentStatus,
bool $auto,
string $createdDate,
string $description,
array $transactions,

Refund

public function refund(Order $order) {
    
    $refundRequestDto = new RefundRequest(
        amount: $order->price,
        orderId: $order->payriff_payment_id
    );
    
    // Returns bool
    $this->payriffClient->refund($refundRequestDto);
    
    ...
}

NOTE: The refund request is used to cancel a payment for an order. This functionality is available within a limited period (specified by the bank) after a payment has been executed.

Exceptions

Consider catching exceptions and providing user-friendly errors

like

use \Nasimic\Payriff\Exceptions\OrderCreationException;

try {
    $orderResponseDto = $this->payriffClient->createOrder($orderRequestDto);
} catch (OrderCreationException $exception) {
    // log error $exception->getMessage()
    // print user-friendly message
}

Documentation

For more detailed information please check Payriff Documentation page.

What is next?

These functions on TODO list. Will be added soon

  • AutoPay

Credits

nasimic/payriff 适用场景与选型建议

nasimic/payriff 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 8, 最近一次更新时间为 2025 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 nasimic/payriff 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-15