承接 farzai/kapi-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

farzai/kapi-sdk

最新稳定版本:0.0.1

Composer 安装命令:

composer require farzai/kapi-sdk

包简介

This SDK simplifies the process of integrating with KBank APIs

README 文档

README

(Work in progress)

Latest Version on Packagist Tests Total Downloads

Welcome to the KBank API SDK for PHP! This SDK simplifies the process of integrating with KBank APIs by providing a set of pre-built functions that handle authentication, requests, and responses. With this SDK, developers can easily build applications that leverage KBank services, such as payment processing, account management, and more. The KBank API SDK for PHP is designed to be easy to use, with clear documentation and examples to get you started quickly.

Documentation

See full documentation at https://farzai.gitbook.io/kbank-kapi-php

Requirements

{
    "php": "^8.0",
    "ext-json": "*",
    "ext-curl": "*"
}

Support products

Done Products
- QR Payment
- Bill Payment
- Slip Verification
- Inward Remittance
- KGP Merchant Payment Platform
- Corporate Fund Transfer

Please note

This project is still under development.

  • OAuth2 Authentication
  • Setup environment and test suite
  • Documentation
  • Implement products
  • Webhook callback capture
  • Code coverage must >= 80%
  • Add support two-way SSL authentication
  • Release v1.0.0

Installation

You can install the package via composer:

composer require farzai/kapi-sdk

Usage

This is a simple example of qr payment.

use Farzai\KApi\ClientBuilder;
use Farzai\KApi\OAuth2\Requests as OAuth2Requests;
use Farzai\KApi\QrPayment\Requests as QrPaymentRequests;

// Create client instance
$client = ClientBuilder::make()
    ->setConsumer("<YOUR_CONSUMER_ID>", "<YOUR_CONSUMER_SECRET>")
    ->asSandbox()
    ->build();


// This SDK will automatically generate oauth2 access token for you.
// You can ignore this step !!
// $accessToken = $client->oauth2
//     ->sendRequest(new OAuth2Requests\RequestAccessToken())
//     ->throw()
//     ->json('access_token');

Next, Build qr code payment request

$yourTransactionId = 'TS'.time();

$request = new QrPaymentRequests\RequestThaiQRCode();
$request
    // Required
    ->setMerchant(id: '<YOUR_MERCHANT_ID>')
    ->setPartner(
        partnerTransactionID: $yourTransactionId,
        partnerID: '<YOUR_PARTNER_ID>',
        partnerSecret: '<YOUR_PARTNER_SECRET>',
        requestDateTime: new \DateTime('now'),
    )
    ->setAmount(100)
    ->setReferences('<YOUR_ORDER_ID>')
    // or ->setReferences('<reference1>', '<reference2>', '<reference3>', '<reference4>')

    // Optional
    ->setTerminal('<YOUR_TERMINAL_ID>')
    ->setCurrency('THB') // Default is THB
    ->setMetadata([
        'แก้วเบียร์ 40บ.',
        'เหล้าขาว 60บ.',
    ]);

// Send request
$response = $client->qrPayment->sendRequest($request);

// Print response data
print_r($response->json());

// Or, you can get response data with specific key
echo $response->json('partnerTxnUid'); // Output: xxxxxxx

Sometime, you may want to handle webhook from payment notification service

use Farzai\KApi\QrPayment;

// This SDK will automatically validate your request.
$result = $client->processWebhook(new QrPayment\PaymentNotificationCallback);

$result->json() // returns: array
$result->json('partnerTxnUid') // returns: string
$result->isSuccessful() // returns: bool

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

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.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-06