karen_he / avataxclient
AvaTax套件的企业税务计算和处理服务的客户端库。使用REST v2 API。更新为使用Guzzle 7以兼容Laravel。
20.14
2021-05-25 04:02 UTC
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ~7
Requires (Dev)
- phpunit/phpunit: 5.7
- dev-master
- 20.14.x-dev
- 20.14
- 20.13
- 20.12.1
- 20.9.0
- 20.8.0
- 20.7.0
- 20.6.0
- 20.5.0
- 20.1.1
- 20.1.0
- 19.12.1
- 19.11.0
- 19.10.0
- 19.9.0
- 19.8.0
- 19.7.0.1
- 19.7.0
- 19.6.0
- 19.5.0
- 19.4.0
- 19.3.0
- 19.2.0
- 19.1.1
- 18.12.0
- 18.10.5.260
- 18.9.0.234
- 18.5.1.208
- 18.4.4.191
- 18.4.3.191
- 18.3.1.176
- 18.2.0.167
- 18.1.2.161
- 17.12.0.149
- 17.12.0.147
- 17.8.1.120
- 17.7.0.96
- 17.5.0.67
- 2.17.4.58
- 2.17.3.48
- 2.17.2.43
- 2.17.1.3
- 2.17.1
This package is auto-updated.
Last update: 2024-09-25 11:31:54 UTC
README
此GitHub存储库是Avalara世界级税务服务AvaTax的PHP SDK。它使用AvaTax REST v2 API,这是一个完整的REST实现,提供对AvaTax所有功能的单一客户端。有关AvaTax REST v2的更多信息,请访问Avalara开发者网络或查看在线Swagger文档。
构建状态
Packagist
Travis-CI
安装PHP SDK
AvaTax PHP SDK作为Composer包提供。
要使用Composer中的AvaTax PHP SDK
- 将
composer.json
文件添加到您的项目中并链接到AvaTax
{ "require": { "avalara/avataxclient": "*" } }
- 运行
composer install
以下载最新版本。
使用PHP SDK
PHP SDK使用流畅的接口来定义与AvaTax的连接以及进行API调用以计算交易中的税费。以下是一个连接到API的示例。
<?php // Include the AvaTaxClient library require __DIR__ . '/vendor/autoload.php'; use Avalara\AvaTaxClient; // Create a new client $client = new Avalara\AvaTaxClient('phpTestApp', '1.0', 'localhost', 'sandbox'); $client->withSecurity('myUsername', 'myPassword'); // If I am debugging, I can call 'Ping' to see if I am connected to the server $p = $client->ping(); echo('<h2>Ping</h2>'); echo('<pre>' . json_encode($p, JSON_PRETTY_PRINT) . '</pre>'); if ($p->authenticated == true) { echo '<p>Authenticated!</p>'; } // Create a simple transaction for $100 using the fluent transaction builder $tb = new Avalara\TransactionBuilder($client, "DEFAULT", Avalara\DocumentType::C_SALESINVOICE, 'ABC'); $t = $tb->withAddress('SingleLocation', '123 Main Street', null, null, 'Irvine', 'CA', '92615', 'US') ->withLine(100.0, 1, null, "P0000000") ->create(); echo('<h2>Transaction #1</h2>'); echo('<pre>' . json_encode($t, JSON_PRETTY_PRINT) . '</pre>'); // Now, let's create a more complex transaction! $tb = new Avalara\TransactionBuilder($client, "DEFAULT", Avalara\DocumentType::C_SALESINVOICE, 'ABC'); $t = $tb->withAddress('ShipFrom', '123 Main Street', null, null, 'Irvine', 'CA', '92615', 'US') ->withAddress('ShipTo', '100 Ravine Lane', null, null, 'Bainbridge Island', 'WA', '98110', 'US') ->withLine(100.0, 1, null, "P0000000") ->withLine(1234.56, 1, null, "P0000000") ->withExemptLine(50.0, null, "NT") ->withLine(2000.0, 1, null, "P0000000") ->withLineAddress(Avalara\TransactionAddressType::C_SHIPFROM, "123 Main Street", null, null, "Irvine", "CA", "92615", "US") ->withLineAddress(Avalara\TransactionAddressType::C_SHIPTO, "1500 Broadway", null, null, "New York", "NY", "10019", "US") ->withLine(50.0, 1, null, "FR010000") ->create(); echo('<h2>Transaction #2</h2>'); echo('<pre>' . json_encode($t, JSON_PRETTY_PRINT) . '</pre>'); ?>