faizulramir/senangpay
Composer 安装命令:
composer require faizulramir/senangpay
包简介
A Laravel package for integrating SenangPay payment gateway
README 文档
README
A Laravel package for integrating SenangPay payment gateway into your Laravel applications.
Features
- Easy integration with SenangPay payment gateway
- Support for both sandbox and production environments
- Form-based payment submission
- Payment response handling
- Hash verification for secure transactions
- Configurable through environment variables
Requirements
- PHP >= 8.1
- Laravel >= 10.0
- Composer
Installation
- Install the package via Composer:
composer require faizulramir/senangpay
- Publish the configuration file:
php artisan vendor:publish --provider="Faizulramir\Senangpay\SenangpayServiceProvider"
- Add the following environment variables to your
.envfile:
SENANGPAY_MERCHANT_ID=your_merchant_id
SENANGPAY_SECRET_KEY=your_secret_key
SENANGPAY_IS_SANDBOX=true
Configuration
The package configuration file (config/senangpay.php) contains the following options:
return [ 'merchant_id' => env('SENANGPAY_MERCHANT_ID'), 'secret_key' => env('SENANGPAY_SECRET_KEY'), 'is_sandbox' => env('SENANGPAY_IS_SANDBOX', true), ];
Usage
Basic Payment Form
use Faizulramir\Senangpay\Senangpay; class PaymentController extends Controller { public function showPaymentForm() { $senangpay = new Senangpay(); return view('payment.form', compact('senangpay')); } }
In your Blade view:
<form action="{{ $senangpay->getPaymentUrl() }}" method="POST">
@csrf
<input type="hidden" name="detail" value="Order #123">
<input type="hidden" name="amount" value="100.00">
<input type="hidden" name="order_id" value="ORDER123">
<input type="hidden" name="name" value="John Doe">
<input type="hidden" name="email" value="john@example.com">
<input type="hidden" name="phone" value="60123456789">
<input type="hidden" name="hash" value="{{ $senangpay->generateHash([
'detail' => 'Order #123',
'amount' => '100.00',
'order_id' => 'ORDER123'
]) }}">
<button type="submit">Pay Now</button>
</form>
Handling Payment Response
public function handlePaymentResponse(Request $request) { $senangpay = new Senangpay(); if ($senangpay->verifyHash($request->all())) { // Payment successful return view('payment.success'); } // Payment failed return view('payment.failed'); }
Available Methods
getPaymentUrl()
Returns the SenangPay payment URL based on the environment (sandbox/production).
generateHash(array $data)
Generates a hash for payment verification using the following parameters:
- detail
- amount
- order_id
verifyHash(array $data)
Verifies the payment response hash to ensure the transaction is legitimate.
Important Notes
- Always validate payment responses using the
verifyHash()method - Keep your secret key secure and never expose it in client-side code
- Test thoroughly in sandbox mode before going live
- Make sure to handle both success and failure scenarios in your application
Security
- The package uses SHA256 hashing for secure transaction verification
- All sensitive data is handled server-side
- Environment variables are used for configuration
- Hash verification is implemented to prevent tampering
Support
If you encounter any issues or have questions, please open an issue in the GitHub repository.
License
This package is open-sourced software licensed under the MIT license.
faizulramir/senangpay 适用场景与选型建议
faizulramir/senangpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「gateway」 「laravel」 「Malaysia」 「SenangPay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 faizulramir/senangpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 faizulramir/senangpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 faizulramir/senangpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
Alfabank REST API integration
GovPayNet driver for the Omnipay payment processing library
BlueSnap driver for the Omnipay payment processing library
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-14