定制 linkbridge/sdk-php 二次开发

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

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

linkbridge/sdk-php

Composer 安装命令:

composer require linkbridge/sdk-php

包简介

PHP SDK for the Linkbridge SI + APP e-invoicing API.

README 文档

README

Idiomatic PHP client for the Linkbridge SI + APP API.

use Linkbridge\LinkbridgeClient;

$client = new LinkbridgeClient([
    'base_url'      => 'https://api.linkbridge.ng',
    'client_id'     => getenv('LB_CLIENT_ID'),
    'client_secret' => getenv('LB_CLIENT_SECRET'),
    'scopes'        => ['invoices:read', 'invoices:write'],
]);

$invoice = json_decode(file_get_contents(__DIR__.'/invoice.json'), true);

$accepted = $client->invoices->submit($invoice, [
    'idempotency_key' => LinkbridgeClient::idempotencyKey(),
]);
echo $accepted['irn'].PHP_EOL;

Design notes

  • Zero runtime Composer dependencies. Built on the bundled curl, json, openssl, and hash extensions only. Same posture as the Python SDK (ADR-0022) so the package installs on any FIRS-issued image without composer require.
  • Resource grouping mirrors the Go / Node / Python SDKs: client->invoices->{submit,get,list,transmit,updateStatus}, client->webhooks->{create,list,delete}, client->lookups->*.
  • OAuth2 client-credentials with a lazy in-memory token cache refreshed 60 seconds before expiry. Pass a static_token to bypass the OAuth dance for ops scripts.
  • Pluggable transport: any class implementing Linkbridge\Transport\TransportInterface can replace CurlTransport, which is what the unit tests do (no live HTTP needed).
  • Webhook verifier in Linkbridge\Webhook::verify() mirrors the reference implementation in the API server byte-for-byte.

Requirements

  • PHP 8.1+
  • Extensions: curl, json, openssl, hash (all in php-core)

Install

Until we publish to Packagist, install via VCS:

{
  "repositories": [
    { "type": "vcs", "url": "https://github.com/linkbridge-systems/linkbridge" }
  ],
  "require": {
    "linkbridge/sdk-php": "^0.1"
  }
}

…or just copy src/ into your project — there are no transitive deps.

Running the tests

docker run --rm -v "$PWD:/app" -w /app php:8.3-cli \
  php vendor/bin/phpunit --testdox

The included composer.json has no runtime requires; phpunit/phpunit is a require-dev only and is fetched the first time you run composer install.

Webhook verification

use Linkbridge\Webhook;
use Linkbridge\SignatureError;

try {
    Webhook::verify(
        secret: $secretBytes,                // raw bytes from POST /v1/webhooks
        body:   file_get_contents('php://input'),
        header: $_SERVER['HTTP_X_LINKBRIDGE_SIGNATURE'] ?? '',
    );
} catch (SignatureError $e) {
    http_response_code(401);
    return;
}

Webhook::verify() enforces the same 5-minute replay window the server-side verifier uses and compares the digest in constant time via hash_equals.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-07-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固