PHPackages                             janfish/tax-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. janfish/tax-api

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

janfish/tax-api
===============

Tax Reporting Interface

14PHP

Since Sep 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/zeng444/tax-api)[ Packagist](https://packagist.org/packages/janfish/tax-api)[ RSS](/packages/janfish-tax-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

税务对接 SDK
========

[](#税务对接-sdk)

初始化客户端
------

[](#初始化客户端)

```
use Tax\Http\Client as HttpClient;

$opt= [
  'connectTimeout' => 1,
    'logFile' => DEMO_PATH.'/logs/api.history.log',
    'cacheFile' => DEMO_PATH.'/logs/token',
    'systemId' => '..........',
    'gatewayUrl' => 'http://.............',
    'rsaPubPath' => DEMO_PATH.'/configs/rsa_public_key.pem',
];

$client = new HttpClient($opt);

```

TOKEN维护重写
---------

[](#token维护重写)

- 继承重写Tax\\Http\\Client下缓存方法
- 返回对象包含 token和expires\_at属性即可

```
protected function setTokenToCache($data);
protected function getTokenToCache();

print_($client->getTokenToCache())
```

输出

```
stdClass Object
{
  [token] =>'xxxxxxxxxxxxx'
  [expires_at] =>'2019-09-06'
}
```

服务调用
----

[](#服务调用)

### 获取token

[](#获取token)

```
use Tax\Requests\TokenRequest;

$token = new TokenService();
$result = $client->execute($token);
if (!$result->isSuccess()) {
    echo 'msg:'.$result->getMessage().PHP_EOL;
    echo 'code:'.$result->getCode().$result->getCodeMsg().PHP_EOL;
    exit;
}
$data = $result->getData();
echo $data->token ?? '';

```

### 所得税汇总

[](#所得税汇总)

```
$reportRequest = new IndividualIncomeTaxRequest();
$reportRequest->setTaxDateRange('2019-09-05', '201-09-06');
$reportRequest->setTaxpayerUUId('?');
$reportRequest->setTaxpayerCompany('?');
$reportRequest->setTaxpayer('?');
$reportRequest->setTaxIndustryCode('?');
$types = array_keys(Collection::TAX_TYPE_MAP);
foreach ($types as $type) {
    $reportRequestCollection = new Collection();
    $reportRequestCollection->setTaxType($type);
    $reportRequestCollection->setTaxCategory('结算结束');
    $reportRequestCollection->serTaxBaseTotal(1000);
    $reportRequestCollection->serTaxRate(0.5);
    $reportRequestCollection->setTaxPayableTotal('212313');
    $reportRequestCollection->setTaxReducedTotal('22');
    $reportRequestCollection->setTaxPaidTotal('22');
    $reportRequestCollection->setAgentTaxChargeableTotal('22');
    $reportRequestCollection->setAgentTaxPaidTotal('22');
    $reportRequestCollection->setTaxOrigin('22', '?', "?");
    $reportRequest->addCollection($reportRequestCollection);
}
$result = $client->execute($reportRequest);
print_r($client->debug());
if (!$result->isSuccess()) {
    echo 'msg:'.$result->getMessage().PHP_EOL;
    echo 'code:'.$result->getCode().$result->getCodeMsg().PHP_EOL;
    exit;
}
$data = $result->getData();
return $data ?? '';
```

### 其他我懒得写

[](#其他我懒得写)

.............

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/60a62fd9f299f25558ac4a898ae3833bd7185ba4706bb167a8cabf05a3d96955?d=identicon)[Robert Zeng](/maintainers/Robert%20Zeng)

---

Top Contributors

[![zeng444](https://avatars.githubusercontent.com/u/941266?v=4)](https://github.com/zeng444 "zeng444 (33 commits)")

### Embed Badge

![Health badge](/badges/janfish-tax-api/health.svg)

```
[![Health](https://phpackages.com/badges/janfish-tax-api/health.svg)](https://phpackages.com/packages/janfish-tax-api)
```

###  Alternatives

[eminiarts/nova-tabs

Laravel Nova - Tabs.

4624.1M20](/packages/eminiarts-nova-tabs)[inspheric/nova-defaultable

Default values for Nova fields when creating resources and running resource actions.

51174.8k1](/packages/inspheric-nova-defaultable)[functional-php/pattern-matching

Pattern matching for PHP with automatic destructuring.

8261.5k](/packages/functional-php-pattern-matching)[awcodes/light-switch

Plugin to add theme switching (light/dark/system) to the auth pages for Filament Panels

4789.9k2](/packages/awcodes-light-switch)[stepanenko3/nova-cards

A Laravel Nova info cards.

33143.0k](/packages/stepanenko3-nova-cards)[scuttlebyte/laravel-request-context

Store and access contextual request data with ease

1570.2k](/packages/scuttlebyte-laravel-request-context)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
