melogail/telr-laravel
Composer 安装命令:
composer require melogail/telr-laravel
包简介
Laravel Telr payment gateway solutions package.
README 文档
README
Laravel package to make online payments from your website via "Telr" payment gateway.
Installation
You can install the package via composer:
composer require melogail/telr-laravel
You can publish and run the migrations with:
php artisan vendor:publish --provider="Melogail\TelrLaravel\TelrLaravelServiceProvider" --tag="migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Melogail\TelrLaravel\TelrLaravelServiceProvider" --tag="config"
This will add the config/telr-laravel.php config file inside your project config folder.
Inside the config/telr-laravel.php config file you will need to add the relative path to success, decline, and cancel page
according to your project route.
return [ // ...other configs 'response_path' => [ 'return_auth' => '/:path/to_success_page', 'return_decl' => '/:path/to_decline_page', 'return_can' => '/:path/to_cancel_page', ], ];
Add the following code to your .env file and change the values to your payment values.
TELR_STORE_ID= # Payment API key [its different from your "Service API" key]. TELR_AUTH_KEY= # Payment API key. TELR_TEST_MODE= # 1=Test mode | 0=Live mode. TELR_CURRENCY= # Currency used for payment.
Add TelrLaravel facade inside your config/app.php file.
'aliases' => Facade::defaultAliases()->merge([ // 'ExampleClass' => App\Example\ExampleClass::class, 'TelrLaravel' => \Melogail\TelrLaravel\Facades\TelrLaravel::class, ])->toArray(),
Usage
To make payment you need to invoke the TelrLaravel class in your controller.
use Melogail\TelrLaravel\TelrLaravel; $telr_laravel = new TelrLaravel();
Use makePayment() method to make payment.
$telr_laravel->makePayment('183-487-143', 9.50, 'Cart generated by John Doe on 2023-1-16');
After calling the makePayment() method, then you call for pay() method to perform the payment.
The makePayment(string $order_id, float $amount, string $description) method requires three parameters:
string $order_id: The order ID generated by your system.float $amount: The amount to be paid in decimals ex: 9.50.string $description: A short description for the payment, max length 63 characters.
While the pay(<array $params>) method accepts one optional parameter as an array that holds the essential billing information required
by the payment gateway. If these parameters are ignored in your system, the payment gateway page will prompt the user to
add these information.
The required information is as follows:
bill_fname: The user first name.bill_sname: The user sure name.bill_addr1: The main billing address.bill_phone: The user phone number.bill_city: The city, ex: Dubai.bill_country: The country, MUST be supplied as a two character ISO 3166 country code, ex: US, GB, EG.bill_email: User main email.
$billing_parameters = [ 'bill_fname' => $first_name, 'bill_sname' => $sure_name, 'bill_addr1' => $address1, 'bill_phone' => $phone, 'bill_city' => $city, 'bill_country' => $country, 'bill_email' => $email ]; $telr_laravel->makePayment('183-487-143', 9.50, 'Cart generated by John Doe on 2023-1-16') ->pay($billing_parameters);
Full code example:
use Melogail\TelrLaravel\TelrLaravel; $telr_laravel = new TelrLaravel(); $billing_parameters = [ 'bill_fname' => $first_name, 'bill_sname' => $sure_name, 'bill_addr1' => $address1, 'bill_phone' => $phone, 'bill_city' => $city, 'bill_country' => $country, 'bill_email' => $email ]; $telr_laravel->makePayment('183-487-143', 9.50, 'Cart generated by John Doe on 2023-1-16')->pay($billing_parameters);
For more information about the billing parameters, check the platform documentation here
Confirm Transaction and Update Transaction Status
After setting up payment status path pages inside your config/telr-laravel.php file, you need to create three different views, each for each status (Success, Decline, Cancel).
Inside each view you need to call the setTransactionStatus(Request $request) method on the Telr facade to update the transaction status based on its response return.
use Illuminate\Http\Request; use \Melogail\TelrLaravel\Facades\TelrLaravel; class PaymentController extends Controller { public function success(Request $request){ // Calling setTransactionStatus facade. TelrLaravel::setTransactionStatus($request); return view( //... success view page); } public function decline(Request $request){ // Calling setTransactionStatus facade. TelrLaravel::setTransactionStatus($request); return view( //... decline view page); } public function cancel(Request $request){ // Calling setTransactionStatus facade. TelrLaravel::setTransactionStatus($request); return view( //... cancel view page); } }
Testing Cards
You can use the following cards to test your payment gateway integration.
| Card number | Type | CVV | MPI |
|---|---|---|---|
| 4000 0000 0000 0002 | Visa | 123 | No |
| 4111 1111 1111 1111 | Visa | 123 | Yes |
| 4444 3333 2222 1111 | Visa | 123 | Yes |
| 4444 4244 4444 4440 | Visa | 123 | Yes |
| 4444 4444 4444 4448 | Visa | 123 | Yes |
| 4012 8888 8888 1881 | Visa | 123 | Yes |
| 5105 1051 0510 5100 | Mastercard | 123 | No |
| 5454 5454 5454 5454 | Mastercard | 123 | Yes |
| 5555 5555 5555 4444 | Mastercard | 123 | Yes |
| 5555 5555 5555 5557 | Mastercard | 123 | Yes |
| 5581 5822 2222 2229 | Mastercard | 123 | Yes |
| 5641 8209 0009 7002 | Maestro UK | 123 | Yes |
| 6767 0957 4000 0005 | Solo | 123 | No |
| 3434 343434 34343 | American Express | 1234 | No |
| 3566 0020 2014 0006 | JCB | 123 | No |
| 3111 1111 1111 1111 | MADA | 123 | No |
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
melogail/telr-laravel 适用场景与选型建议
melogail/telr-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 170 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「telr」 「melogail」 「telr_laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 melogail/telr-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 melogail/telr-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 melogail/telr-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Pay online through telr payment gateway
Omnipay gate way for Telr.com
This Omnipay-based bundle provides basic payment logic for Symfony applications.
Alfabank REST API integration
Pay online with Telr payment gateway through Laravel
Pay online through telr payment gateway
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-24