supplycart/e-invoice

PHP的MyInvois包装器

1.0.1 2024-08-12 01:37 UTC

This package is auto-updated.

Last update: 2024-09-12 01:55:22 UTC


README

要安装,请运行

$ composer require supplycart/e-invoice

与Laravel(已在Laravel 11上测试)一起使用

以纳税人系统登录

use Supplycart\EInvoice\EInvoiceClient;
use Illuminate\Support\Facades\Cache;

$isProd = false;
$clientId = '5b75ce93-a6d1-4e02-943f-a24ffa1b46ec';
$clientSecret = 'e4d2fcc8-90a8-40cd-99be-08f3401fbb93';

$client = new EInvoiceClient(
    clientId: $clientId,
    clientSecret: $clientSecret,
    isProd: isProd
);

$client->login();

$accessToken = $client->getAccessToken();

//Alternative to store in cache and get it later
Cache::remember('some-key', $accessToken, 3600) // expires in 3600s (1hour)

// To reuse the cached accessToken
$client->setAccessToken(Cache::get('some-key'));

以中介系统登录

// same as login, just need to set $onBehalfOf which is the entity's TIN
$client->setOnBehalfOf($onBehalfOf); 

验证纳税人的TIN

$tin = 'C1234567890';
$idType = 'BRN';
$idValue = '1234567890';

$response = $client->validateTaxPayerTin(
    tin: $tin,
    idType: $idType,
    idValue: $idValue
);

获取文档详情

$documentUuid = '5a282618-8ad0-4ad6-bc1d-7f2a326562cf';

$response = $client->getDocumentDetail($documentUuid);