定制 rstacode/nass 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

rstacode/nass

Composer 安装命令:

composer require rstacode/nass

包简介

Laravel SDK for Nass Payment Gateway - Iraq

README 文档

README

Latest Version on Packagist Total Downloads License

650479278_1546030170859165_3518304600250512091_n

Laravel SDK for the Nass Payment Gateway — Iraq's payment processing platform.

Requirements

  • PHP 8.1+
  • Laravel 10.x, 11.x, 12.x, or 13.x

Installation

composer require rstacode/nass

Laravel auto-discovers the service provider. Publish the config file:

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

Configuration

Add the following to your .env file:

# Merchant credentials
NASS_USERNAME=your_merchant_username
NASS_PASSWORD=your_merchant_password

# Environment URLs
# UAT:        https://uat-gateway.nass.iq:9746
# Production: https://gateway.nass.iq:9746
NASS_BASE_URL=https://uat-gateway.nass.iq:9746

NASS_TIMEOUT=30

Usage

1. Authentication

Login with your merchant credentials to receive a Bearer access token:

use Nass\Facades\Nass;

// Uses credentials from config (NASS_USERNAME / NASS_PASSWORD)
$response = Nass::auth()->login();
$token = $response['data']['access_token'];

// Or pass credentials manually
$response = Nass::auth()->login('your_username', 'your_password');
$token = $response['data']['access_token'];

// Set the token for all subsequent requests
Nass::setToken($token);

2. Create a Transaction

use Nass\Facades\Nass;

// Set Token
$loginResponse = Nass::auth()->login();
Nass::setToken($loginResponse['data']['access_token']);

// Create Transaction
$response = Nass::transactions()->create([
    'orderId'         => '123456',
    'orderDesc'       => 'Purchase of electronics',
    'amount'          => 150.00,
    'currency'        => '368',       // 368 = Iraqi Dinar (IQD)
    'transactionType' => '1',
    'backRef'         => 'https://yoursite.com/payment/callback',
    'notifyUrl'       => 'https://yoursite.com/payment/notify',
]);

// Redirect the customer to complete payment
$paymentUrl = $response['data']['url'];

return redirect($paymentUrl);

Response example:

{
  "success": true,
  "code": 0,
  "status_code": 200,
  "data": {
    "url": "https://3dsecure.nass.iq/gateway/{Transaction Parameters}",
    "pSign": "18f...",
    "transactionParams": {
      "TERMINAL": "<TERMINAL_ID>",
      "TRTYPE": "1",
      "AMOUNT": "150",
      "ORDER": "123456"
    }
  }
}

3. Check Transaction Status

Note: Status checks are available within 24 hours of transaction initiation. For long-term reference use the rrn field.

use Nass\Facades\Nass;

// Set Token
$loginResponse = Nass::auth()->login();
Nass::setToken($loginResponse['data']['access_token']);

// Check Transaction
$status = Nass::transactions()->checkStatus('123456');

echo $status['data']['statusMsg'];    // "Approved"
echo $status['data']['responseCode']; // "00" = success
echo $status['data']['rrn'];          // Transaction reference number

4. Handling Callbacks

The Nass gateway will POST the transaction result to your notifyUrl:

// routes/web.php
Route::post('/payment/notify', [PaymentController::class, 'handleCallback']);
// PaymentController.php
public function handleCallback(Request $request): void
{
    $data = $request->all();

    // responseCode "00" = approved
    if ($data['responseCode'] === '00' && $data['actionCode'] === '0') {
        // Payment successful — store $data['rrn'] as reference
    }
}

Callback payload fields:

Field Description
terminal Terminal ID
actionCode 0 = success
responseCode 00 = approved
card Masked card number
amount Transaction amount
currency Currency code (368 = IQD)
rrn Reference number in acquiring bank
intRef Internal reference (used for reversals)
orderId Your order ID (stored 7 days only)
tranDate Transaction date/time
transactionOrigin local or international

5. Error Handling

use Nass\Facades\Nass;
use Nass\Exceptions\NassException;

try {
    Nass::setToken($token);

    $response = Nass::transactions()->create([...]);
} catch (NassException $e) {
    $statusCode = $e->getCode();
    $message    = $e->getMessage();
    $response   = $e->getResponse();
}

UAT Test Cards

Use these cards exclusively in the UAT environment:

PAN Expiry CVV
5123450000000008 01/39 100

API Environments

Environment Base URL
UAT https://uat-gateway.nass.iq:9746
Production https://gateway.nass.iq:9746

License

MIT

rstacode/nass 适用场景与选型建议

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

它主要适用于以下技术方向: 「payment」 「sdk」 「gateway」 「laravel」 「iraq」 「nass」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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