定制 giorgijorji/laravel-tbc-installment 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

giorgijorji/laravel-tbc-installment

Composer 安装命令:

composer require giorgijorji/laravel-tbc-installment

包简介

TBC installment for laravel

README 文档

README

Latest Stable Version Software License Total Downloads Downloads Month

This package allows you to use TBC Installment in your Laravel application. Package is actively maintained :)

Laravel TbcPay

Table of Contents

Installation

composer require giorgijorji/laravel-tbc-installment

For Laravel <= 5.4

If you're using Laravel 5.4 or lower, you have to manually add a service provider in your config/app.php file. Open config/app.php and add TbcPayServiceProvider to the providers array.

'providers' => [
    # Other providers
    Giorgijorji\LaravelTbcInstallment\TbcInstallmentServiceProvider::class,
],

Then run:

php artisan vendor:publish --provider="Giorgijorji\LaravelTbcInstallment\TbcInstallmentServiceProvider"

Getting Access Token

In order to access Online Installment endpoints, merchant application should request access token with Oauth2 Client Credential flow. apiKey and apiSecret values should be passed as client_id and client_secret. This operation is used to verify registered developer app and grant general access to the Open API platform. To get your apiKey and apiSecret, follow instructions at developers.tbcbank.ge/get-started

Environment

After getting apiKey, apiSecret, merchantKey and campaignId place them in .env.

Set your environment variables:

TBC_ENVIRONMENT=testing
TBC_INSTALLMENT_API_KEY=your_api_key
TBC_INSTALLMENT_API_SECRET=your_api_secret
TBC_INSTALLMENT_MERCHANT_KEY=your_merchant_key
TBC_INSTALLMENT_CAMPAIGN_ID=your_campaing_id

Usage

<?php

use Giorgijorji\LaravelTbcInstallment\LaravelTbcInstallment;

# Create new instance of LaravelTbcInstallment
$tbcInstallment = new LaravelTbcInstallment();
# Adding Single Product Example | Array
# Single Product structure and parameter types (name => string, price => float, quantity => integer) are validated upon adding
# If invalid product structure or parameters provided it will throw InvalidProductException
$product = [
    'name' => "SampleProduct", // string - product name
    'price' => 12.33, // Value in GEL (decimal numbering); Note that if Quantity is more than 1, you must set total price
    'quantity' => 1, // integer - product quantity
];
# Call AddProduct

$tbcInstallment->addProduct($product);

# Adding Multiple Products Example | Array => (Array)
# Single Product structure and parameter types (name => string, price => float, quantity => integer) are validated upon adding
# If invalid product structure or parameters provided will throw InvalidProductException
$products = [
    [
        'name' => "SampleProduct1", // string - product name
        'price' => 12.33, // Value in GEL (decimal numbering); Note that if Quantity is more than 1, you must set total price
        'quantity' => 1, // integer - product quantity
    ],
    [
        'name' => "SampleProduct2", // string - product name
        'price' => 24.66, // Value in GEL (decimal numbering); Note that if Quantity is more than 1, you must set total price
        'quantity' => 2, // integer - product quantity
    ],
];
# Call AddProducts , that gets array of products

$tbcInstallment->addProducts($products);

# To check or get added products you can simply call getProducts(), which will return array of products
$addedProducts = $tbcInstallment->getProducts();

/*
* @param string your invoiceId - 
* The unique value of your system that is attached to the application, for example, is initiated by you
* Application Id which is in your database.
* When a customer enters into an installment agreement on the TBC Installment Site, you will receive this InvoiceId by email along with other details.
* @param invoiceId must identify the application on your side.
* @param decimal total price of all Products
* On apply total price provided and products price sum is validated, else will throw exception
* On apply if products are empty will throw ProductsNotFoundException
* On apply if products price total sum and total price not equal it will throw InvalidProductPriceException
*/
$response = $tbcInstallment->applyInstallmentApplication(1, 12.33);

# After applyInstallmentApplication you can get sessionId and redirect url to tbc installment web page
if ($response['status_code'] === 200) {
    $sessionId = $tbcInstallment->getSessionId(); // string - session id for later use to cancel  installment
    $redirectUri = $tbcInstallment->getRedirectUri(); // string - redirect uri to tbc installment webpage
    # save session id to your database
    # then you can simply call laravel redirect method
    return redirect($redirectUri);
} # else error acquired

# After that the application will processed by TBC you will receive this InvoiceId by email along with other details.
# Only after that you can Confirm or Cancel Installment application via your admin panel or as you wish
# Confirm Installment application example
$response = $tbcInstallment->confirm($invoiceId, $sessionId, $priceTotal);
if ($response['status_code'] === 200) {
 # TODO HERE YOUR STUFF
} # else error acquired

# Cancel Installment application example, $sessionId is previously saved sessionId
$response = $tbcInstallment->cancel($sessionId);
if ($response['status_code'] === 200) {
 # TODO HERE YOUR STUFF
} # else error acquired

# applyInstallmentApplication, confirm and cancel methods will return status code and message
# example of response
# status code 200 means all ok, any other status code is fail of request
$response = [
    'status_code' => 200,
    'message' => 'ok',
];

# That's all :)

Result Codes

status_code message Description
200 Ok Application Confirmed
401 Unauthorized Invalid Token provided for oAuth

To Add more status

TODO

  • unit tests

Credits

  • Any suggestions or improvement requests accepted
  • Z3R0

giorgijorji/laravel-tbc-installment 适用场景与选型建议

giorgijorji/laravel-tbc-installment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「tbc」 「installment」 「giorgijorji」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 giorgijorji/laravel-tbc-installment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 giorgijorji/laravel-tbc-installment 我们能提供哪些服务?
定制开发 / 二次开发

基于 giorgijorji/laravel-tbc-installment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 89
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-31