承接 shahinsoft/irbanks 相关项目开发

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

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

shahinsoft/irbanks

Composer 安装命令:

composer require shahinsoft/irbanks

包简介

Iranian banks payment gateways interface

README 文档

README

Iranian banks payment gateways Interface

Introduction

This library provides a simple and easy way to accept payments using Iranian banks with PHP.

Installation

simply install IRbanks using composer:

composer require shahinsoft/irbanks

How to use?

Each bank has its own payment process, end-points, and parameters. First of all you need to know about the process of your bank. Then refer to your bank section in this document.

Mellat

Mellat payment has 3 main steps; getting the payment toke, verifying the payment, and settling the payment.

1. Get payment token

try{
    $mellat = new \IRbanks\Mellat($terminalId, $userName, $userPassword);
    $response = $mellat->request($amount);
}catch(\Throwable $e){
    echo "error: ".$e->getMessage();
}

2. Redirect user to payment page

//use $response info like token($response->token) and orderId($response->order_id) to create a HTML form with POST method
//or automatically do it using redirectToMellat() function
    $response->redirectToMellat();

//This function generates a JS script which creates a hidden HTML form with POST method to redirect the end-user to the Mellat payment page.

3. Verify payment

try{
    $mellat = new \IRbanks\Mellat($terminalId, $userName, $userPassword);
    $response = $mellat->verify();
    update_your_payment_with($response->reference_id,$response->order_id,$response->card_number);
    echo "successful payment";
}catch(\Throwable $e){
    //payment was unsuccessful or verification failed
    echo "error: ".$e->getMessage();
}

Parsian

Parsian payment has 3 main steps; getting the payment token, redirecting user to payment page, and verifying the payment. There is a possibility to reverse a transaction as well. (Last test: 25 July 2023)

1. Get payment token

<?php 
use IRbanks\Parsian;

try{
    $parsian = new Parsian($pin);
    $response = $parsian->request($amount, $callbackUrl, $orderId, $additionalData);
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

2. Redirect user to the payment page

//use payment URL ($parsian->paymentUrl()) to redirect user to the payment page with your project standards
//or call redirect function ($parsian->redirect()) for automatic redirect using header location

//manual approach
$payment_url = $parsian->paymentUrl();
return redirect($payment_url);

//automatic approach
$parsian->redirect();

3. Verify payment

<?php
use IRbanks\Parsian;

try{
    $parsian = new Parsian($pin);
    $response = $parsian->verify();
    update_your_payment_with($response->token,$response->order_id,$response->RNN,$response->hash_card_number);
    echo "Successful payment";
}catch (\Throwable $exception){
    //payment was unsuccessful or verification failed
    echo $exception->getMessage();
}

4. Reversing a transaction

In case you do not verify a transaction you can reverse it.

<?php
use IRbanks\Parsian;

try{
    $parsian = new Parsian($pin);
    $parsian->reverse($token);
    echo "Transaction reversed successfully";
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

Asan Pardakht

Asan Pardakht payment has 3 main steps; getting the payment toke, verifying the payment, and settling the payment.

1. Get payment token

try{
    $AP = new \IRbanks\Asanpardakht($merchantId, $username, $password, $aesKey, $aesIV);
    $response = $AP->request($amount, $callback_url, $order_id);
}catch(\Throwable $e){
    echo "error: ".$e->getMessage();
}

2. Redirect user to payment page

//use $response info like token($response->token) and refId($response->refID) to create a HTML form with POST method
//or automatically do it using redirectToAsanpardakht() function.
    $response->redirectToAsanpardakht();

//This function generates a JS script which creates a hidden HTML form with POST method to redirect the end-user to the Asanpardakht payment page.

3. Verify payment

try{
    $AP = new \IRbanks\Asanpardakht($merchantId, $username, $password, $aesKey, $aesIV);
    $optional_REQUEST_parameter = Request::input('ReturningParams'); //This is an optional parameter, if not set, the $_POST will be used
    $response = $AP->verify($optional_REQUEST_parameter);

    // OR
    $response = $AP->verify();

    update_your_payment_with($response->reference_id,$response->order_id,$response->card_number,$response->asanpardakht_transaction_id);
    echo "successful payment";
}catch(\Throwable $e){
    //payment was unsuccessful or verification failed
    echo "error: ".$e->getMessage();
}

Sadad (Bank Melli)

Sadad payment has 3 main steps; getting the payment toke, redirecting user to payment page, and verifying the payment.

1. Get payment token

Note: Your callback url should contain order_id cause Sadad does not return it to call back url.

try{
    $Sadad = new \IRbanks\Sadad($terminalId, $merchant, $transactionKey);
    $response = $Sadad->request($amount, $callback_url, $order_id);
}catch(\Throwable $e){
    echo "error: ".$e->getMessage();
}

2. Redirect user to payment page

//use $response info like token($response->token) and refId($response->refID) to create a HTML form with POST method
//or automatically do it using redirectToAsanpardakht() function.
    $response->redirectToAsanpardakht();

//This function generates a JS script which creates a hidden HTML form with POST method to redirect the end-user to the Asanpardakht payment page.

3. Verify payment

try{
    $AP = new \IRbanks\Asanpardakht($merchantId, $username, $password, $aesKey, $aesIV);
    $optional_REQUEST_parameter = Request::input('ReturningParams'); //This is an optional parameter, if not set, the $_POST will be used
    $response = $AP->verify($optional_REQUEST_parameter);

    // OR
    $response = $AP->verify();
    
    update_your_payment_with($response->reference_id,$response->order_id,$response->card_number,$response->asanpardakht_transaction_id);
    echo "successful payment";
}catch(\Throwable $e){
    //payment was unsuccessful or verification failed
    echo "error: ".$e->getMessage();
}

shahinsoft/irbanks 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-20