sudhanshu-mittal / telr-laravel
通过 telr 支付网关在线支付
dev-master
2023-03-14 14:44 UTC
This package is auto-updated.
Last update: 2024-09-14 17:53:43 UTC
README
安装
您可以通过 composer 安装此包
composer require sudhanshu-mittal/telr-laravel
从 Laravel 5.5 版本开始,服务提供者将自动注册。在框架的旧版本中,只需将服务提供者添加到 config/app.php
文件中
'providers' => [ // ... SudhanshuMittal\TelrGateway\TelrServiceProvider::class, ];
您可以使用以下提供者进行发布
php artisan vendor:publish --provider="SudhanshuMittal\TelrGateway\TelrServiceProvider"
之后,您可以通过运行迁移命令来创建 telr 交易表
php artisan migrate
发布后,配置文件 config/telr.php
包含以下内容
return [ // The current mode is live|production or test 'test_mode' => env('TELR_TEST_MODE', true), // The currency of store 'currency' => 'SAR', // The sale endpoint that receive the params // @see https://telr.com/support/knowledge-base/hosted-payment-page-integration-guide 'sale' => [ 'endpoint' => 'https://secure.telr.com/gateway/order.json', ], // The hosted payment page use the following params as it explained in the integration guide // @see https://telr.com/support/knowledge-base/hosted-payment-page-integration-guide/#request-method-and-format 'create' => [ 'ivp_method' => "create", 'ivp_store' => env('TELR_STORE_ID', null), 'ivp_authkey' => env('TELR_STORE_AUTH_KEY', null), 'return_auth' => '/handle-payment/success', 'return_can' => '/handle-payment/cancel', 'return_decl' => '/handle-payment/declined', ] ];
使用方法
创建路由后,将以下代码放置在要跳转到银行页面的位置
$telrManager = new \SudhanshuMittal\TelrGateway\TelrManager(); $billingParams = [ 'first_name' => 'Robert', 'sur_name' => 'Evans', 'address_1' => 'Gnaklis', 'address_2' => 'Gnaklis 2', 'city' => 'Alexandria', 'region' => 'San Stefano', 'zip' => '11231', 'country' => 'EG', 'email' => 'example@company.com', ]; $req_params = [ 'user_id' => 5, 'product_id' => 2, 'amount' => 500, 'short_desc' => 'cart items request payload', ]; return $telrManager->pay('ORDER_ID_GOES_HERE', 'TOTAL_AMOUNT', 'DESCRIPTION ...', $billingParams, $req_params)->redirect();
- 注意,如果您想避免在创建处理支付的令牌时发送账单参数,则适用此操作,并且
Telr 托管支付页面
将需要它,并在 check 请求中获取客户信息。
- 此外,如果您想避免在创建处理支付的令牌时发送请求参数,则适用此操作。req_params 帮助您了解您启动交易请求的请求数据包。
在 telr 回调 (Success|Cancel|Declined) 中处理响应时,请放置以下代码
$telrManager = new \SudhanshuMittal\TelrGateway\TelrManager(); $telrManager->handleTransactionResponse($request);