plaramart/tbi-bank

保加利亚TBI银行API封装器

1.0.0 2022-06-25 18:07 UTC

This package is auto-updated.

Last update: 2024-09-26 23:45:24 UTC


README

这是一个保加利亚TBI银行的独立API封装器。用作支付方式/定期支付。询问单一/所有方案的运算以及其他更多内容;

安装

composer require plaramart/tbi-bank

使用

初始化

无框架初始化

$client = new \Plaramart\TbiBank\Client('your-api-secret', __DIR__.'/folder/pub.pem');

使用Laravel框架初始化,或者您可以安装我的Laravel实现

// Inside AppServiceProvider.php
$this->app->singleton(\Plaramart\TbiBank\Client::class, function () {    
    $apiSecretKey = 'your-api-secret';
    $pathToCert = storage_path('app/pub.pem');
    return new \Plaramart\TbiBank\Client($apiSecretKey, $pathToCert);
});

获取计算结果

所有方案

获取所有方案的运算结果。您只能传递第一个参数(价格)以获取所需的所有数据。其他参数不是必需的,但您可以在需要时填写它们。

// (float $price, float $initialPayment = 0, int $category = 10, $insurance = 'n')
$calculationRequest = new \Plaramart\TbiBank\Requests\CalculateForAllPeriodSchemesRequest(
    price: 113
);

$response = $client->execute($calculationRequest);

单一方案

第二个参数是$period。这是您想要的特定方案,例如calc(price: 113, period: 3)

// (float $price, int $period = 3, float $initialPayment = 0, int $category = 10, $insurance = 'n')
$calculationRequest = new \Plaramart\TbiBank\Requests\CalculateForPeriodRequest(
    price: 113, 
    period: 3
);

$response = $client->execute($calculationRequest);

提交订单到TBI

$order = new CreateOrderRequest(price: 113, months: 3, initialPayment: 50);

$order->setUser(
    name: 'Zgdevv LordGeorgex', 
    id: 9808027528, 
    address: 'Na borovets batko', 
    phone: '+35988888888', 
    email: 'me@gmail.com'
);

// You can add as much as u want products. 
// Product ID from your database. nothing to do with their API
$order->addProduct(
    id: 1, 
    name: 'test', 
    quantity: 2, 
    price: 113
);

$response = $client->execute($order);

贡献

发送PR以修复错误或改进。联系邮箱:zgdevv@gmail.com

许可证

MIT