承接 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

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固