rajtika/sslcommerz
Composer 安装命令:
composer require rajtika/sslcommerz
包简介
SSLCommerce Payment gateway Integration library for laravel
README 文档
README
SSLCommerz payment gateway integration
This package will make your integration to SSLCommerz payment gateway simple and easy
Installation
You can install the package via composer:
composer require rajtika/sslcommerz
Publish Configuration
Publish configuration file
php artisan vendor:publish
Setup and configure
Update your app environment (.env)
SSL_LOCALHOST=[TRUE/FALSE]
SSL_SANDBOX_MODE=[TRUE/FALSE]
SSL_STORE_ID=[YOUR SSLCOMMERZ STORE ID]
SSL_STORE_PASSWORD=[YOUR SSLCOMMERZ STORE_PASSWORD]
SSL_SUCCESS_URL=sslcommerz/success
SSL_CANCEL_URL=sslcommerz/cancel
SSL_FAIL_URL=sslcommerz/fail
SSL_IPN_URL=sslcommerz/ipn
SSL_STORE_CURRENCY=[STORE CURRENCY eg. BDT]
Create four POST routes for SSLCommerz
Route::post('sslcommerz/success','SSLPaymentController@success'); Route::post('sslcommerz/fail','SSLPaymentController@fail'); Route::post('sslcommerz/cancel','SSLPaymentController@cancel'); Route::post('sslcommerz/ipn','SSLPaymentController@ipn');
NOTE These routes are being used in .env file
Add exception in app\Http\Middleware\VerifyCsrfToken.php
protected $except = [ 'sslcommerz/*' ];
NOTE This will be the initial group of those four routes
After done configuraing
php artisan config:cache
Usage
Make Payment
Now you can call for payment from Route or Controller method:
Route Way
Route::post('make-payment', function() { SSLCommerz::setParams([ 'tran_id' => 'your_unique_transaction_id', 'product_name' => 'Name of your product', 'product_category' => 'Product category', 'product_profile' => 'general', 'total_amount' => 100, 'currency' => 'BDT', 'cus_name' => 'John Doe', 'cus_email' => 'customer@example.com', 'cus_phone' => '01911XXXXXX', 'cus_add1' => 'Dhaka' ]) //Shipping is required when your order need shipment ->setShippingInfo([ 'shipping_method' => "YES", 'num_of_item' => 2 ]) ->makePayment() ->hosted(); //this method will redirect your customer to ssl commerz payment page //or ->checkout(); //this method will return a json response for your checkout popup });
Controller Way
use Rajtika\SSLCommerz\SSLCommerz; class PaymentController extends Controller { public function paymentRedirectWay() { ... // DO YOU ORDER SAVING PROCESS TO DB OR ANYTHING ... // You can generate an unique transaction id by using uniqueid() $transaction_id = uniqid(); //this transaction id must save your order or payment table for referencing / validate payment status return SSLCommerz::setParams([ 'tran_id' => $transaction_id, 'product_name' => 'Name of your product', 'product_category' => 'Product category', 'product_profile' => 'general', 'total_amount' => 100, 'currency' => 'BDT', 'cus_name' => 'John Doe', 'cus_email' => 'customer@example.com', 'cus_phone' => '01911XXXXXX', 'cus_add1' => 'Dhaka' ]) //Shipping is required when your order need shipment ->setShippingInfo([ 'shipping_method' => "YES", 'num_of_item' => 2 ]) ->makePayment() ->hosted(); //this method will redirect your customer to ssl commerz payment page } //or public function popupWay() { ... // DO YOU ORDER SAVING PROCESS TO DB OR ANYTHING ... // You can generate an unique transaction id by using uniqueid() /* * this transaction id must save your order or payment table * for referencing / validate payment status * You can make this more unique by passing prefix to it */ $transaction_id = uniqid(); return SSLCommerz::setParams([ 'tran_id' => $transaction_id, 'product_name' => 'Name of your product', 'product_category' => 'Product category', 'product_profile' => 'general', 'total_amount' => 100, 'currency' => 'BDT', 'cus_name' => 'John Doe', 'cus_email' => 'customer@example.com', 'cus_phone' => '01911XXXXXX', 'cus_add1' => 'Dhaka' ]) //Shipping is required when your order need shipment ->setShippingInfo([ 'shipping_method' => "YES", 'num_of_item' => 2 ]) ->makePayment() ->checkout(); //this method will return a json response for your checkout popup } }
NOTE This is the minimalist basic need to perform a payment.
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
rajtika/sslcommerz 适用场景与选型建议
rajtika/sslcommerz 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 04 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「api」 「payment」 「gateway」 「integration」 「Bangladeshi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rajtika/sslcommerz 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rajtika/sslcommerz 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rajtika/sslcommerz 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Simple ASCII output of array data
Package for view storage in laravel
User Approval Laravel Package
PHPUnit Pretty Result Printer
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-18