定制 kalimeromk/casys-laravel 二次开发

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

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

kalimeromk/casys-laravel

Composer 安装命令:

composer require kalimeromk/casys-laravel

包简介

Integration of casys payment method

关键字:

README 文档

README

This is a package to integrate the Casys payment gateway into Laravel. It generates complete scaffolding for simple integration, including support for recurring payments.

Features

  1. Views
    • resources/views/vendor/casys
  2. Configuration
    • config/casys.php
  3. Controllers
    • /Http/Controllers/CasysController
    • /Http/Controllers/RecurringPaymentController
  4. Recurring Payment Support
    • /Http/Services/RecurringPayment.php
    • Example integration for managing recurring payments using SOAP services.
  5. Routes
    • Predefined routes for standard and recurring payments.

Installation

Require this package by running:

composer require kalimeromk/casys-laravel

After installation, publish the package files:

php artisan vendor:publish --provider="Kalimero\Casys\CasysServiceProvider"

This will publish the following files:

  • config/casys.php
  • resources/views/vendor/casys

Laravel Setup

Register the route file in your RouteServiceProvider or add the following routes to your existing route file:

Standard Payment Routes

use App\Http\Controllers\CasysController;

Route::get('paymentLoader', [CasysController::class, 'index'])->name('loader');
Route::post('payment', [CasysController::class, 'getCasys'])->name('validateAndPay');
Route::post('paymentOKURL', [CasysController::class, 'success'])->name('paymentOKURL');
Route::post('paymentFailURL', [CasysController::class, 'fail'])->name('paymentFailURL');

Recurring Payment Routes

use KalimeroMK\Casys\Controllers\RecurringPaymentController;

Route::post('/recurring-payment', [RecurringPaymentController::class, 'handleRecurringPayment'])->name('recurring.payment');

For Laravel <=7, use the controller string syntax:

Route::get('paymentLoader', 'CasysController@index')->name('loader');
Route::post('payment', 'CasysController@getCasys')->name('validateAndPay');
Route::post('paymentOKURL', 'CasysController@success')->name('paymentOKURL');
Route::post('paymentFailURL', 'CasysController@fail')->name('paymentFailURL');

How to Use

Configuration

Add your credentials to the .env file:

PAY_TO_MERCHANT=your_merchant_id
MERCHANT_NAME=your_merchant_name
AMOUNT_CURRENCY=MKD
PAYMENT_OK_URL=your_success_url
PAYMENT_FAIL_URL=your_fail_url
CASYS_TOKEN=your_token

Standard Payments

For standard payments, simply pass the amount and client data to the appropriate method in the CasysController. The views provided by the package will handle the UI. If you wish to customize the views, edit the published views in resources/views/vendor/casys.

Recurring Payments

The package includes support for recurring payments through the RecurringPayment class and RecurringPaymentController. Here’s how you can integrate it:

Recurring Payment Parameters

The recurring payment requires the following parameters:

  • RPRef: A string containing details about the recurring payment, formatted as:
    RPRef = RequestType,BillingCycle,MaxBCycles,BillingAmount,BillingCycleStart
    
  • RPRefID: Unique ID returned during the initial registration of the recurring transaction.

Example Workflow

  1. Initial Registration The cardholder performs the initial transaction with the RPRef parameter set. The system returns an RPRefID, which you should store for future recurring payments.

  2. Subsequent Payments Use the stored RPRefID to initiate subsequent payments without user involvement.

Example Request

Call the /recurring-payment endpoint with the following payload:

{
    "merchant_id": "YourMerchantID",
    "rp_ref": "R,1M,12,500000,20240101",
    "rp_ref_id": "UniqueRPRefID",
    "amount": 500000,
    "password": "YourMerchantPassword"
}

Example Recurring Payment Integration

You can use the RecurringPayment service class in your application:

use KalimeroMK\Casys\Services\RecurringPayment;

$recurringPayment = new RecurringPayment();

$response = $recurringPayment->sendPayment(
    $merchantId,
    $rpRef,
    $rpRefId,
    $amount,
    $password
);

if ($response['success']) {
    echo "Recurring payment successful! Reference: " . $response['payment_reference'];
} else {
    echo "Recurring payment failed: " . $response['error_description'];
}

Provided Controllers

CasysController

Handles the standard payment flow, including:

  • Loading the payment page (paymentLoader route).
  • Validating and processing payments (payment route).
  • Handling success (paymentOKURL route) and failure (paymentFailURL route) callbacks.

RecurringPaymentController

Handles recurring payment requests via the /recurring-payment route. Example integration is included for making SOAP calls to the Casys gateway.

Info

This package is in an alpha stage and is designed to be flexible for your specific needs. Suggestions are welcome!

kalimeromk/casys-laravel 适用场景与选型建议

kalimeromk/casys-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.52k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2020 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 19
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-21