定制 flick/flick-php-sdk 二次开发

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

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

flick/flick-php-sdk

Composer 安装命令:

composer require flick/flick-php-sdk

包简介

A php wrapper for interacting with the APIs of Flick.

README 文档

README

Platform Platform Software License

A php interface for interacting with the APIs of Flick.

Installation

To use the Flick Php SDK in your project, you can install it via composer:

composer require flick/flick-php-sdk

Getting Started

Before using the package, you need to configure it with your API credentials. You should have an apiKey and specify whether you are using the 'sandbox' or 'production' environment.

Here's how you to initiate our SDK in your project:

use Flick\FlickPhpSdk\Bills;
use Flick\FlickPhpSdk\Config;

// Initialize the Bills class with your API key and specify the environment ('sandbox' or 'production')
$bills = new Bills(new Config('sandbox', 'your-api-key-here'));

Note

You may need to import the autoload file depending on the framework (or lack thereof) you choose

require 'vendor/autoload.php';

Documentation

To learn about available methods and their usage, please refer to the official API documentation. Here's a glimpse to our Bills Module:

Bills Client

The Bills client provides access to various functionalities for managing bills. You can interact with the following API endpoints:

Onboard EGS to ZATCA:

$egs_data = [ /* your EGS data goes here*/ ]

$response = $bills->onboard_egs($egsData)->wait();
print($response->getBody()->getContents());

Compliance Check:

$egs_uuid = 'egs-uuid';

$response = $bills->do_compliance_check($egs_uuid);
print($response->getBody()->getContents());

Generate E-Invoice for Phase-2 in Saudi Arabia:

$invoice_data = [ /* your Invoice data goes here*/ ]

$response = $bills->generate_invoice($egsData)->wait();
print($response->getBody()->getContents());

Examples

  1. Here's an Example of how you can onboard multiple EGS to ZATCA Portal [If you are onboarding PoS devices or VAT-Group members, this comes handy].

  2. Examples are included in the examples folder as well

<?php

// Include the necessary dependencies
use Flick\FlickPhpSdk\Bills;
use Flick\FlickPhpSdk\Config;

// Initialize the Bills class with your API key and specify the environment ('sandbox' or 'production')
$bills = new Bills(new Config('sandbox', 'your-api-key-here'));

// Define the data for onboarding EGS
$egsData = [
  'vat_name' => 'Test Co.',
  'vat_number' => '300000000000003',
  'devices' => [
    [
      'device_name' => 'TestEGS1',
      'city' => 'Riyadh',
      'city_subdiv' => 'Test Dist.',
      'street' => 'Test St.',
      'plot' => '1234',
      'building' => '1234',
      'postal' => '12345',
      'branch_name' => 'Riyad Branch 1',
      // This will be a 10-digit TIN if you are onboarding a VAT-Group Member
      'branch_industry' => 'Retail',
      'otp' => '123321',
    ],
    [
      'device_name' => 'TestEGS2',
      'city' => 'Riyadh',
      'city_subdiv' => 'Test Dist.',
      'street' => 'Test St.',
      'plot' => '1234',
      'building' => '1234',
      'postal' => '12345',
      'branch_name' => 'Riyad Branch 2',
      // This will be a 10-digit TIN if you are onboarding a VAT-Group Member
      'branch_industry' => 'Retail',
      'otp' => '321123',
    ],
  ],
];

// Perform the EGS onboarding operation asynchronously and handle the result or error
$promise = $bills->onboard_egs($egsData);

$promise->then(function ($result) {
  // Handle the successful result
  print($result);
})->otherwise(function ($exception) {
  // Handle the error 
  print($exception->getResponse()->getBody()->getContents());
})->wait();

 
  1. Here's an Example of how you can Genereate a ZATCA-Complied E-Invoice.
<?php
require '../vendor/autoload.php';

// Include the necessary dependencies

use Flick\FlickPhpSdk\Bills;
use Flick\FlickPhpSdk\Config;

// Initialize the Bills class with your API key and specify the environment ('sandbox' or 'production')
$bills = new Bills(new Config('sandbox', 'your-api-key-here'));

// Define the data for generating invoice

$invoiceData = [
  'egs_uuid' => '7b9cc231-0e14-4bff-938c-4603fe10c4bc',
  'invoice_ref_number' => 'INV-5',
  'issue_date' => '2023-01-01',
  'issue_time' => '01:40:40',
  'party_details' => [
    'party_name_ar' => 'شركة اختبار',
    'party_vat' => '300001111100003',
    'party_add_id' => [
      'crn' => 45463464,
    ],
    'city_ar' => 'جدة',
    'city_subdivision_ar' => 'حي الشرفية',
    'street_ar' => 'شارع الاختبار',
    'plot_identification' => '1234',
    'building' => '1234',
    'postal_zone' => '12345',
  ],
  'doc_type' => '388',
  'inv_type' => 'standard',
  'payment_method' => 10,
  'currency' => 'SAR',
  'total_tax' => 142.0,
  'has_advance' => true,
  'advance_details' => [
    'advance_amount' => 575,
    'total_amount' => 2875,
    'advance_invoices' => [
      [
        'tax_category' => 'S',
        'tax_percentage' => 0.15,
        'taxable_amount' => 500,
        'tax_amount' => 75,
        'invoices' => [
          [
            'id' => 'INV-1',
            'issue_date' => '2022-12-10',
            'issue_time' => '12:28:17',
          ],
        ],
      ],
    ],
  ],
  'lineitems' => [
    [
      'name_ar' => 'متحرك',
      'quantity' => 1,
      'tax_category' => 'S',
      'tax_exclusive_price' => 750,
      'tax_percentage' => 0.15,
    ],
    [
      'name_ar' => 'حاسوب محمول',
      'quantity' => 1,
      'tax_category' => 'S',
      'tax_exclusive_price' => 1750,
      'tax_percentage' => 0.15,
    ],
  ],
];



// Perform the EGS onboarding operation asynchronously and handle the result or error
$promise = $bills->generate_invoice($invoiceData);

$promise->then(function ($result) {
  // Handle the successful result
  print($result);
})->otherwise(function ($exception) {
  // Handle the error 
  print($exception->getResponse()->getBody()->getContents());
})->wait();

Contributing

We welcome contributions from the community. If you find issues or have suggestions for improvements, please open an issue or create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please contact our support team at support@flick.network

Keywords

einvoicing, e-invoicing, zatca, phase2, saudi, ksa, fatoora, saudiarabia, egs

flick/flick-php-sdk 适用场景与选型建议

flick/flick-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 10 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 flick/flick-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-24