mantraideas/laravel-connectips 问题修复 & 功能扩展

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

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

mantraideas/laravel-connectips

Composer 安装命令:

composer require mantraideas/laravel-connectips

包简介

Laravel Connectips Payment Gateway Integration

README 文档

README

Laravel Connectips

Laravel Connectips

Latest Stable Version Total Downloads License

The mantraideas/laravel-connectips allows you to integrate ConnectIps payment on your Laravel Application.

Quick Start

Install Using Composer

composer require mantraideas/laravel-connectips

Publish Config File

php artisan vendor:publish --provider="MantraIdeas\LaravelConnectips\LaravelConnectipsServiceProvider"

This will create a config/connectips.php file in your Laravel application. If you want to change the default configuration, you can do so in this file.

Set Environment Variables

You can set the environment variables in your .env file:

CONNECTIPS_MERCHANT_ID=""
CONNECTIPS_APP_ID=""
CONNECTIPS_PASSWORD=""
CONNECTIPS_APP_NAME=""
CONNECTIPS_SUCCESS_URL=${APP_URL}/connectips/success/
CONNECTIPS_FAILURE_URL=${APP_URL}/connectips/failure
CONNECTIPS_PEM_PATH="app/private/privatekey.pem"
CONNECTIPS_URL="https://uat.connectips.com"

Here is the description of each environment variable:

  • CONNECTIPS_MERCHANT_ID: Your Connectips Merchant ID. (Provided by Connectips)
  • CONNECTIPS_APP_ID: Your Connectips App ID. (Provided by Connectips)
  • CONNECTIPS_PASSWORD: Your Connectips Password. (Provided by Connectips)
  • CONNECTIPS_APP_NAME: Your Connectips App Name. (Provided by Connectips)
  • CONNECTIPS_SUCCESS_URL: The URL to redirect to after a successful payment.
  • CONNECTIPS_FAILURE_URL: The URL to redirect to after a failed/canceled payment.
  • CONNECTIPS_PEM_PATH: The path to the private key file. (File provided by Connectips) Note: It must be inside storage directory.
  • CONNECTIPS_URL: The URL to the Connectips API. (Default is https://uat.connectips.com for testing.)

Usage

 $connectips = new \Mantraideas\LaravelConnectips\LaravelConnectips();
 // Create Unique Transaction Id
    $transactionId = uniqid('txn_');
    // Generate Transaction Details
    $transactionDetails = $connectips->generateData(
        transactionId: $transactionId,
        transactionAmount: 5000, // amount in paisa i.e. 5000 paisa = 50.00 NPR
        referenceId: 'REF_' . uniqid(),
        remarks: 'Payment for service',
        particulars: 'Service payment',
        transactionDate: now()->format('d-m-Y'),
        transactionCurrency: 'NPR'
    );
    // Store Payment on Database
    \App\Models\Payment::create(
        [
            'transaction_id' => $transactionId,
            'amount'=>$transactionDetails['TXNAMT'],
            'status'=>'Pending'
        ]
    );
    // Pass Transaction Details to View
    return view('welcome', [
        'connectIpsUrl' => config('connectips.connectIpsUrl').'/connectipswebgw/loginpage',
        'transaction' => $transactionDetails,
        'successUrl' => route('payment.success'),
        'failureUrl' => route('payment.failure')
    ]);

Create Payment Form

You can create a payment form using the transaction details generated above. Here is an example of how to create a payment form in your Blade view:

<!DOCTYPE html>
<html>
<head>
    <title>Connectips Gateway</title>
</head>
<body>
<div class="form-container">
    <h1>Connect IPS Payment Form</h1>
    <form action="{{ $connectIpsUrl }}" method="POST">
        @foreach($transaction as $key => $value)
        <div class="form-field">
            <label for="{{ $key }}">{{ $key }}:</label>
            <input type="text" id="{{ $key }}" name="{{ $key }}" value="{{ $value }}" readonly>
        </div>
        @endforeach
        <button type="submit" class="submit-btn">Make Payment</button>
    </form>
</div>
</body>
</html>

After this user will be redirected to connectips payment webpage and then after the action user will be redirected to Success or Fail callback url based on the payment status. Then you can use the following code to handle the success and failure callback.

Validate Payment Status

Additionally, you can validate payment status using the validatePayment method. This method will check the payment status and return a boolean value. You will get transaction_id from the response of Connectips API to your success and failed payment callback url. You can use the following code to validate the payment status. By using the transaction_id you can check your payments table to get amount and use this method.

    $connectips = new \Mantraideas\LaravelConnectips\LaravelConnectips();
    $transactionId = request()->query('TXNID'); // Replace with the actual transaction ID
    $transactionAmount = \App\Models\Payment::where('transaction_id',$transactionId)->first()?->amount; // Replace with the actual transaction amount
    $paymentValidation = $connectips->validatePayment($transactionId,$transactionAmount);

This will return transaction status as follows.

array:7 [▼ 
  "merchantId" => "Your Merchant Id"
  "appId" => "Your App Id"
  "referenceId" => "txn_67f8a3e7055fa"
  "txnAmt" => "5000" // Amount in paisa i.e. 5000 paisa = 50.00 NPR
  "token" => null
  "status" => "SUCCESS"
  "statusDesc" => "TRANSACTION SUCCESSFUL"
]

Get Transaction Details

You can also get transaction details using the getTransactionDetails method. This method will return the transaction details as an array.

    $connectips = new \Mantraideas\LaravelConnectips\LaravelConnectips();
    $transactionId = request()->query('TXNID'); // Replace with the actual transaction ID
    $transactionAmount = \App\Models\Payment::where('transaction_id',$transactionId)->first()?->amount; // Replace with the actual transaction amount
    $transactionDetails = $connectips->getTransactionDetails($transactionId);

This will return transaction details as follows.

array:18 [▼ 
  "status" => "SUCCESS"
  "statusDesc" => "TRANSACTION SUCCESSFUL"
  "merchantId" => "Your Merchant ID"
  "appId" => "Your App ID"
  "referenceId" => "txn_67f8a3e7055fa" //this is your transaction id
  "txnAmt" => 5000.0 // amount in paisa i.e. 5000 paisa = 50.00 NPR
  "token" => null
  "debitBankCode" => "2501"
  "txnId" => 13303786
  "batchId" => 712974908
  "txnDate" => 1744348150748
  "txnCrncy" => null
  "chargeAmt" => 225.0 // amount in pasia i.e. 225 paisa = 2.25 NPR
  "chargeLiability" => "CG"
  "refId" => "REF_67f8a3e705600"
  "remarks" => "Payment for service"
  "particulars" => "Service payment"
  "creditStatus" => "DEFER"
]

License

MIT

Author

Support

For support, email dipeshkhanal79[at]gmail[dot]com.

mantraideas/laravel-connectips 适用场景与选型建议

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

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

围绕 mantraideas/laravel-connectips 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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