seerbit / seerbit-laravel
SeerBit Laravel 库
v2.0.3
2024-03-27 08:28 UTC
Requires
- php: ^8.0
- illuminate/support: ~8|~9
- seerbit/seerbit-php-sdk: ^2.3.2
Requires (Dev)
- phpunit/phpunit: ^8.0 || ^9.0
README
SeerBit 的 API SDK 用于 Laravel
SeerBit PHP SDK 用于轻松集成 SeerBit 的 API。
需求
此包可与 Laravel 5.8 或更高版本,PHP 8.0 或更高版本一起使用
安装
首选方法是通过 composer。如果您尚未安装 composer,请遵循 composer 的 安装说明。
安装 composer 后,请在项目根目录中执行以下命令以安装此库
composer require seerbit/seerbit-laravel
服务提供程序将自动注册自己。
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="SeerbitLaravel\SeerbitServiceProvider" --tag="config"
以下是配置文件的内容,将发布到您的应用目录路径 config/seerbit.php
return [ 'environment' => env('SEERBIT_ENVIRONMENT', \Seerbit\Environment::LIVE), 'public_key' => env('SEERBIT_PUBLIC_KEY'), 'secret_key' => env('SEERBIT_SECRET_KEY'), 'token' => env('SEERBIT_TOKEN'), ];
您可以从您的商家仪表板中找到公钥和私钥。
您可以按照以下指南生成令牌 这里
通过更改您的 .env 文件中的键值来替换它们。
打开您的 .env 文件并添加您的公钥、私钥和令牌
SEERBIT_PUBLIC_KEY=xxxxxxxxxxxxx SEERBIT_SECRET_KEY=xxxxxxxxxxxxx SEERBIT_TOKEN=xxxxxxxxxxxxx
如果您正在使用 Lambda 等云托管服务,您可能需要将上述详细信息添加到您的环境变量部分。
ENSURE YOU DO NOT PUBLISH YOUR ENV FILE TO YOUR GIT REPOSITORY
使用方法
标准结账
namespace App\Http\Controllers; use SeerbitLaravel\Facades\Seerbit; class Standard { public function Checkout(){ try{ $uuid = bin2hex(random_bytes(6)); $transaction_ref = strtoupper(trim($uuid)); $payload = [ "amount" => "1000", "callbackUrl" => "http:yourwebsite.com", "country" => "NG", "currency" => "NGN", "email" => "customer@email.com", "paymentReference" => $transaction_ref, "productDescription" => "product_description", "productId" => "64310880-2708933-427", "tokenize" => true //optional ]; // Initialize the payment with the Facade // Or with Facade $trans = SeerBit::Standard()->Initialize($payload); // You can get your redirect link for customer payment from $tran $redirectLink = $trans['data']['payments']['redirectLink']; // Redirect to this link in order to complete the transaction if (!empty($redirectLink)) { return redirect($redirectLink)->with("status", $trans['data']['message']); } else { // Something went wrong while initiating the transaction return redirect()->back()->with('error', $trans['data']['message']); } }catch (\Exception $e){ // Handle exception handling } }
完整文档可以在 这里 找到
配置日志记录器
//Set Logger path in environment config file SEERBIT_LOGGER_PATH = ""
API 文档
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
贡献
我们强烈鼓励您加入我们,为这个仓库做出贡献,以便每个人都可以从中受益
- 新功能和功能
- 已解决的问题和问题
- 任何一般改进
安全
如果您发现任何与安全相关的问题,请通过电子邮件 developers@seerbit.com 联系,而不是使用问题跟踪器。
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件