faysal0x1/lara-payment 问题修复 & 功能扩展

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

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

faysal0x1/lara-payment

Composer 安装命令:

composer require faysal0x1/lara-payment

包简介

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

README 文档

README

Latest Version on Packagist PHP from Packagist Laravel Version Test Status Code Style Status Total Downloads

The lara-payment package provides a convenient way to handle payments through multiple payment gateways in a Laravel 8, 9 and 10 application. The package currently supports multiple gateways such as Paystack, Flutterwave and Stripe. The package offers an easy to use interface that abstracts the complexities of integrating with these payment gateways. It also provides a way to handle webhooks from the payment gateways.

Documentation

A comprehensive documentation is available to help you get started with the package here

Testing

php artisan test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel SSLCommerz Payment Gateway Integration

A Laravel package for integrating SSLCommerz payment gateway into your Laravel application. This package provides a simple and flexible way to handle payments through SSLCommerz in your Laravel projects.

Features

  • Easy checkout and hosted checkout options
  • AJAX payment support
  • IPN (Instant Payment Notification) handling
  • Success, fail, and cancel URL handling
  • Order validation
  • Sandbox mode support
  • Multiple payment methods support
  • EMI payment support
  • Customizable payment forms
  • Comprehensive error handling

Requirements

  • PHP >= 7.4
  • Laravel >= 8.0
  • SSLCommerz merchant account

Installation

  1. Install the package via Composer:
composer require faysal0x1/lara-payment
  1. Publish the configuration file:
php artisan vendor:publish --provider="Faysal0x1\LaraPayment\SslcommerzLaravelServiceProvider" --tag="config"
  1. Publish the controller:
php artisan vendor:publish --provider="Faysal0x1\LaraPayment\SslcommerzLaravelServiceProvider" --tag="controllers"
  1. Publish the views:
php artisan vendor:publish --provider="Faysal0x1\LaraPayment\SslcommerzLaravelServiceProvider" --tag="views"
  1. Publish the migrations:
php artisan vendor:publish --provider="Faysal0x1\LaraPayment\SslcommerzLaravelServiceProvider" --tag="migrations"
  1. Run the migrations:
php artisan migrate

Configuration

Add the following environment variables to your .env file:

SSLCOMMERZ_SANDBOX=true
SSLCOMMERZ_STORE_ID=your_store_id
SSLCOMMERZ__STORE_PASSWORD=your_store_password

The configuration file (config/sslcommerz.php) contains the following options:

return [
    'sandbox' => env("SSLCOMMERZ_SANDBOX", false),
    'middleware' => 'web',
    'store_id' => env("SSLCOMMERZ_STORE_ID"),
    'store_password' => env("SSLCOMMERZ__STORE_PASSWORD"),
    'success_url' => '/sslcommerz/success',
    'failed_url' => '/sslcommerz/fail',
    'cancel_url' => '/sslcommerz/cancel',
    'ipn_url' => '/sslcommerz/ipn',
    'return_response' => 'html', // html or json
];

Usage

Basic Payment Integration

  1. Using the Facade:
use Faysal0x1\LaraPayment\Facade\SSLCommerzPayment;

// Make payment
$data = [
    'total_amount' => 100,
    'currency' => 'BDT',
    'tran_id' => uniqid(),
    'product_category' => 'Test Category'
];

$customer = [
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'address_1' => 'Dhaka',
    'phone' => '8801XXXXXXXXX',
    'country' => 'Bangladesh'
];

$shipment = [
    'shipping_method' => 'Yes',
    'ship_name' => 'John Doe',
    'ship_add1' => 'Dhaka',
    'ship_city' => 'Dhaka',
    'ship_country' => 'Bangladesh'
];

$response = SSLCommerzPayment::makePayment($data)
    ->setCustomerInfo($customer)
    ->setShipmentInfo($shipment);
  1. Using the Controller:

Visit /example1 for AJAX payment or /example2 for hosted payment.

Available Routes

Route::get('/example1', [SslCommerzPaymentController::class, 'exampleEasyCheckout']);
Route::get('/example2', [SslCommerzPaymentController::class, 'exampleHostedCheckout']);
Route::post('/pay', [SslCommerzPaymentController::class, 'index']);
Route::post('/pay-via-ajax', [SslCommerzPaymentController::class, 'payViaAjax']);
Route::post('/success', [SslCommerzPaymentController::class, 'success']);
Route::post('/fail', [SslCommerzPaymentController::class, 'fail']);
Route::post('/cancel', [SslCommerzPaymentController::class, 'cancel']);
Route::post('/ipn', [SslCommerzPaymentController::class, 'ipn']);

Advanced Features

  1. EMI Payment Support:
$sslc = new SslCommerzNotification();
$sslc->enableEMI(3, 12, false); // 3 months installment, max 12 months, not restricted to EMI only
  1. Airline Ticket Profile:
$airlineInfo = [
    'hours_till_departure' => '24',
    'flight_type' => 'domestic',
    'pnr' => 'ABC123',
    'journey_from_to' => 'Dhaka to Chittagong'
];
$sslc->setAirlineTicketProfile($airlineInfo);
  1. Travel Vertical Profile:
$travelInfo = [
    'hotel_name' => 'Grand Hotel',
    'length_of_stay' => 3,
    'check_in_time' => '14:00',
    'hotel_city' => 'Dhaka'
];
$sslc->setTravelVerticalProfile($travelInfo);
  1. Telecom Vertical Profile:
$telecomInfo = [
    'product_type' => 'prepaid',
    'topup_number' => '8801XXXXXXXXX',
    'country_topup' => 'Bangladesh'
];
$sslc->setTelecomVerticleProfile($telecomInfo);

Response Handling

  1. Success Response:
return SSLCommerzPayment::returnSuccess($transId, "Transaction is successfully Completed", '/');
  1. Failure Response:
return SSLCommerzPayment::returnFail($transId, "Transaction is Failed", '/');

Database Structure

The package creates an orders table with the following structure:

Schema::create('orders', function (Blueprint $table) {
    $table->id();
    $table->string('name', 191)->nullable();
    $table->string('email', 191)->nullable();
    $table->string('phone', 60)->nullable();
    $table->double('amount')->default(0);
    $table->text('address')->nullable();
    $table->string('status', 20)->default('Pending');
    $table->string('transaction_id', 191);
    $table->string('currency', 20)->nullable()->default('BDT');
    $table->timestamps();
});

Security Considerations

  1. Always use environment variables for sensitive data
  2. Enable SSL on your production environment
  3. Validate all incoming data
  4. Use proper error handling
  5. Keep your store credentials secure

Testing

  1. Set SSLCOMMERZ_SANDBOX=true in your .env file for testing
  2. Use test credentials provided by SSLCommerz
  3. Test all payment scenarios (success, fail, cancel)
  4. Verify IPN handling
  5. Test with different currencies and amounts

Support

For any issues or questions, please create an issue in the GitHub repository.

License

This package is open-sourced software licensed under the MIT license.

faysal0x1/lara-payment 适用场景与选型建议

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

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

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

围绕 faysal0x1/lara-payment 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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