elshaden/laravel-tlync
Composer 安装命令:
composer require elshaden/laravel-tlync
包简介
Laravel SKD for Tlync Payment Gateway
README 文档
README
From Tadawul Digital Solutions Provider , (TDSP)
Overview
This Package is a Laravel SDK for Tlync Payment gateway you can read more about Tlync API here Tlync API Documentation
To use this package you must have an account on Tlync and have your API Key and API Secret
You Also need to create a temporary table in your database to store the new orders before sending them to Tlync This will help in making sure that any completed and paid orders are not sent again to Tlync. and also to make sure that Tlync will only receive unique orders.
How it works
- Customer places and order on your website, or cart
- You create a new order in your temporary table in data database
- You send the order to Tlync as will be explained below
- Tlync will send a callback to your website with the order status
- if the order is paid, you can now create the order in your database and send the customer to the success page
- and delete the temporary order from your temporary table or mark it as paid
- if the order is not paid, you can send the customer to the failed page and delete the order from your temporary table
Installation
You can install the package via composer:
composer require elshaden/laravel-tlync
You must publish the config file with:
php artisan vendor:publish --tag="laravel-tlync-config"
This is the contents of the published config file:
/* * You can Force test environment even if you application is in production. * This will override the environment settings * This is useful for testing. * */ 'force_test_mode' => env('TLYNC_FORCE_TEST_MODE', false), /* * You can restrict the IP address that can access the callback url. * This is useful for security. * */ 'restrict_ip' => false, /* * You can add the IP address that can access the callback url. * You need to request the IP's from Tlync Support */ 'allowed_ips' => [env('TLYNC_ALLOWED_IPS')], /* * The url that will be used to send the request to Tlync. * This is for testing. */ 'tlync_test_url' => 'https://c7drkx2ege.execute-api.eu-west-2.amazonaws.com/', /* * The Store Id in test environment. * You must add this in the .env file, * do not add here. as this file can be pushed to git. */ 'api_test_key' => env('TLYNC_TEST_STORE_ID'), /* * The Store token that will be used to send the request to Tlync test environment. */ 'tlync_test_token' => env('TLYNC_TEST_TOKEN'), /* * Live Production Environment * The url that will be used to send the request to Tlync. * This is for live production. */ 'tlync_live_url' => 'https://wla3xiw497.execute-api.eu-central-1.amazonaws.com/', /* * The Store Id in live environment. * You must add this in the .env file, * do not add here. as this file can be pushed to git. */ 'api_live_key' => env('TLYNC_LIVE_STORE_ID'), /* * The Store token that will be used to send the request to Tlync live environment. * You must add this in the .env file, * do not add here. as this file can be pushed to git. */ 'tlync_live_token' => env('TLYNC_LIVE_TOKEN'), /* * If you want you can direct the call back coming from Tlync to a specific url. * This is useful if you want to handle the call back in a different controller. * Leave as it is the package will handle the call back. */ 'callback_url' => env('APP_URL') . '/api/tlync/callback', /* * This where the customer will be redirected after payment. * if you want to redirect to another page please add this here * example back to MyCart page. or My Orders Page */ 'frontend_url' => env('APP_URL') , /* * The model class that should be used to mark the payment as paid or failed. * Example class \App\Actions\ConfirmOrder\Class. * */ 'handel_call_back_class' => env('TLYNC_PAYMENT_CLASS', ''), /* * The Method in the handel_call_back_class that will be used to mark the payment as paid. * Example method 'confirm' in \App\Actions\ConfirmOrder\Class. * ``` * public function confirm($order, $request){ * // Change order from temporary to orders and deliver the order. * } * ``` * And completes the process if the payment is paid. * */ 'handel_method' => env('METHOD_TO_CONFIRM_PAYMENT', ''),
And Also publishes the Hashids file, if you already have that, please add the custom connections to your file The hashids config is responsible for providing a hashed id for the temporary order id, so the customer will not see the real order id
Usage
Initiate Payment
use Elshaden\Tlync\Facades\Tlync; $Response = Tlync::InitiatePayment ( float $Amount, // The amount of the order $para_1, // this can be the real temprory order id or the customer id $para_2, // this can be the value of the order int $para_3, // this must the real temprory order id, AND MUST BE UNIQUE & INTEGER string $UserPhone, // Customer Phone Number string $UserEmail // Customer Email Address OPTIONAL )
Initiate Payment Response and Redirect
Success Response
if the initiate payment is successful, you will get a response in array
$Response = [ 'Response' => true, 'message' => 'redirect to url', 'url' => 'https://store.pay.net.ly/tdi/xxxxxxxxxxxxx......', ];
You should Redirect the customer to the url provided in the response
if the initiate payment is not successful, you will get a response in array
$Response = [ 'Response' => false, 'message' => 'Error Message', ];
Call Back
This is when Tlync sends a call back to your server Backend with the payment status The route set in the config file will receive the POST call back and will handle it in the Tlync Controller
The verification of the call back is done by Tlync Callback Method, so you do not need to worry about that.
When all is done this package will call the class you set up in the config file
'handel_call_back_class' => env('TLYNC_PAYMENT_CLASS', ''), 'handel_method' => env('METHOD_TO_CONFIRM_PAYMENT', ''),
passing to it the Parameters you sent to the Initiate and the Tlync Response
To learn more about the Tlync Response please check the Tlync Documentation
You will need to handel the call back in your own class and method, and do what ever you want with it Normally if success you will need to create the order in your database and send the customer to the success page and if failed you will need to send the customer to the failed page
You can create your own class and method to handle the call back, and add it to the config file
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.
elshaden/laravel-tlync 适用场景与选型建议
elshaden/laravel-tlync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「laravel-tlync」 「Elshaden」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elshaden/laravel-tlync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elshaden/laravel-tlync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elshaden/laravel-tlync 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-12