avalara / avalara_sdk
API for evaluating transactions against direct-to-consumer Beverage Alcohol shipping regulations. This API is currently in beta.
Requires
- php: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.9.1 || ^2.4.5
- php-ds/php-ds: ^1.4
- psr/log: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12
- guzzlehttp/promises: ^1.4
- monolog/monolog: ^3.2
- phpunit/phpunit: ^8.0 || ^9.0
- vlucas/phpdotenv: ^5.4
README
Unified SDK consists of services on top of which the Avalara Compliance Cloud platform is built. These services are foundational and provide functionality such as einvoicing.
Installation & Usage
Requirements
PHP 7.3 and later. Should also work with PHP 8.0 but has not been tested.
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/avadev/Avalara-SDK-PHP.git" } ], "require": { "avalara/avalara_sdk": "24.12.1" } }
Then run composer install
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure HTTP OAUTH2 Access Token and other config options $config = new \Avalara\SDK\Configuration(); $config->setBearerToken('YOUR_JWT_ACCESS_TOKEN'); $config->setAppName('YOUR_APP_NAME'); $config->setEnvironment('sandbox'); $config->setMachineName('YOUR_MACHINE_NAME'); $config->setAppVersion('YOUR_APP_VERSION'); $client = new \Avalara\SDK\ApiClient($config); $apiInstance = new \Avalara\SDK\API\EInvoicing\V1\MandatesApi($client); $request_options = new \Avalara\SDK\API\EInvoicing\V1\GetMandatesRequest(); $request_options->setXAvalaraClient('Swagger UI; 22.7.0; Custom; 1.0'); // string | Identifies the software you are using to call this API. For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) . try { $result = $apiInstance->getMandates($request_options); print_r("Result: ". $result); } catch (Exception $e) { echo 'Exception when calling AddressesApi->resolveAddressPost: ', $e->getMessage(), PHP_EOL; }
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Logging
All PSR-3 compatible loggers are supported by the SDK.
Usage
Declare whichever PSR-3 logger that you desire and pass it in via the configuration object. The example below uses Monolog
use Monolog\Logger; use Monolog\Handler\StreamHandler; $config = new \Avalara\SDK\Configuration(); // Configure logger $logger = new Logger('AddressLogger'); $logger->pushHandler(new StreamHandler(__DIR__ . '/../../app.log', Logger::DEBUG)); // Setup log options , first parameter is logRequestAndResponseBody, which can be true|false. Second parameter is the PSR-3 compatible logger. $logOptions = new \Avalara\SDK\Utils\LogOptions(true, $logger); $config->setLogOptions($logOptions); $client = new \Avalara\SDK\ApiClient($config);
Documentation for API Endpoints
EInvoicing V1 API Documentation
Class | Method | HTTP request | Description |
---|---|---|---|
DataInputFieldsApi | getDataInputFields | GET /data-input-fields | Returns the optionality of document fields for different country mandates |
DocumentsApi | downloadDocument | GET /documents/{documentId}/$download | Returns a copy of the document |
DocumentsApi | fetchDocuments | POST /documents/$fetch | Fetch the inbound document from a tax authority |
DocumentsApi | getDocumentList | GET /documents | Returns a summary of documents for a date range |
DocumentsApi | getDocumentStatus | GET /documents/{documentId}/status | Checks the status of a document |
DocumentsApi | submitDocument | POST /documents | Submits a document to Avalara E-Invoicing API |
InteropApi | submitInteropDocument | POST /interop/documents | Submit a document |
MandatesApi | getMandateDataInputFields | GET /mandates/{mandateId}/data-input-fields | Returns document field information for a country mandate, a selected document type, and its version |
MandatesApi | getMandates | GET /mandates | List country mandates that are supported by the Avalara E-Invoicing platform |
TradingPartnersApi | batchSearchParticipants | POST /trading-partners/batch-searches | Creates a batch search and performs a batch search in the directory for participants in the background. |
TradingPartnersApi | downloadBatchSearchReport | GET /trading-partners/batch-searches/{id}/$download-results | Download batch search results in a csv file. |
TradingPartnersApi | getBatchSearchDetail | GET /trading-partners/batch-searches/{id} | Get the batch search details for a given id. |
TradingPartnersApi | listBatchSearches | GET /trading-partners/batch-searches | List all batch searches that were previously submitted. |
TradingPartnersApi | searchParticipants | GET /trading-partners | Returns a list of participants matching the input query. |
Documentation for Models
EInvoicing V1 Model Documentation
- Avalara\SDK\Model\EInvoicing\V1\BadDownloadRequest
- Avalara\SDK\Model\EInvoicing\V1\BadRequest
- Avalara\SDK\Model\EInvoicing\V1\BatchSearch
- Avalara\SDK\Model\EInvoicing\V1\BatchSearchListResponse
- Avalara\SDK\Model\EInvoicing\V1\ConditionalForField
- Avalara\SDK\Model\EInvoicing\V1\DataInputField
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldNotUsedFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldOptionalFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldRequiredFor
- Avalara\SDK\Model\EInvoicing\V1\DataInputFieldsResponse
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponse
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerAddressesInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerIdentifiersInner
- Avalara\SDK\Model\EInvoicing\V1\DirectorySearchResponseValueInnerSupportedDocumentTypesInner
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetch
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequest
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequestDataInner
- Avalara\SDK\Model\EInvoicing\V1\DocumentFetchRequestMetadata
- Avalara\SDK\Model\EInvoicing\V1\DocumentListResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentStatusResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentSubmissionError
- Avalara\SDK\Model\EInvoicing\V1\DocumentSubmitResponse
- Avalara\SDK\Model\EInvoicing\V1\DocumentSummary
- Avalara\SDK\Model\EInvoicing\V1\ErrorResponse
- Avalara\SDK\Model\EInvoicing\V1\ForbiddenError
- Avalara\SDK\Model\EInvoicing\V1\InputDataFormats
- Avalara\SDK\Model\EInvoicing\V1\InternalServerError
- Avalara\SDK\Model\EInvoicing\V1\Mandate
- Avalara\SDK\Model\EInvoicing\V1\MandateDataInputField
- Avalara\SDK\Model\EInvoicing\V1\MandateDataInputFieldNamespace
- Avalara\SDK\Model\EInvoicing\V1\MandatesResponse
- Avalara\SDK\Model\EInvoicing\V1\NotFoundError
- Avalara\SDK\Model\EInvoicing\V1\NotUsedForField
- Avalara\SDK\Model\EInvoicing\V1\RequiredWhenField
- Avalara\SDK\Model\EInvoicing\V1\StatusEvent
- Avalara\SDK\Model\EInvoicing\V1\SubmitDocumentMetadata
- Avalara\SDK\Model\EInvoicing\V1\SubmitInteropDocument202Response
- Avalara\SDK\Model\EInvoicing\V1\WorkflowIds
Documentation for API Endpoints
EInvoicing V1 API Documentation
Class | Method | HTTP request | Description |
---|---|---|---|
DataInputFieldsApi | getDataInputFields | GET /data-input-fields | Returns the optionality of document fields for different country mandates |
DocumentsApi | downloadDocument | GET /documents/{documentId}/$download | Returns a copy of the document |
DocumentsApi | fetchDocuments | POST /documents/$fetch | Fetch the inbound document from a tax authority |
DocumentsApi | getDocumentList | GET /documents | Returns a summary of documents for a date range |
DocumentsApi | getDocumentStatus | GET /documents/{documentId}/status | Checks the status of a document |
DocumentsApi | submitDocument | POST /documents | Submits a document to Avalara E-Invoicing API |
InteropApi | submitInteropDocument | POST /interop/documents | Submit a document |
MandatesApi | getMandateDataInputFields | GET /mandates/{mandateId}/data-input-fields | Returns document field information for a country mandate, a selected document type, and its version |
MandatesApi | getMandates | GET /mandates | List country mandates that are supported by the Avalara E-Invoicing platform |
SubscriptionsApi | createWebhookSubscription | POST /webhooks/subscriptions | Create a subscription to events |
SubscriptionsApi | deleteWebhookSubscription | DELETE /webhooks/subscriptions/{subscription-id} | Unsubscribe from events |
SubscriptionsApi | getWebhookSubscription | GET /webhooks/subscriptions/{subscription-id} | Get details of a subscription |
SubscriptionsApi | listWebhookSubscriptions | GET /webhooks/subscriptions | List all subscriptions |
TradingPartnersApi | batchSearchParticipants | POST /trading-partners/batch-searches | Creates a batch search and performs a batch search in the directory for participants in the background. |
TradingPartnersApi | downloadBatchSearchReport | GET /trading-partners/batch-searches/{id}/$download-results | Download batch search results in a csv file. |
TradingPartnersApi | getBatchSearchDetail | GET /trading-partners/batch-searches/{id} | Get the batch search details for a given id. |
TradingPartnersApi | listBatchSearches | GET /trading-partners/batch-searches | List all batch searches that were previously submitted. |
TradingPartnersApi | searchParticipants | GET /trading-partners | Returns a list of participants matching the input query. |
A1099 V2 API Documentation
Class | Method | HTTP request | Description |
---|---|---|---|
CompaniesW9Api | createCompany | POST /w9/companies | Creates a new company |
CompaniesW9Api | deleteCompany | DELETE /w9/companies/{id} | Deletes a company |
CompaniesW9Api | getCompanies | GET /w9/companies | List companies |
CompaniesW9Api | getCompany | GET /w9/companies/{id} | Retrieve a company |
CompaniesW9Api | updateCompany | PUT /w9/companies/{id} | Update a company |
Forms1099Api | bulkUpsert1099Forms | POST /1099/forms/$bulk-upsert | Creates or updates multiple 1099 forms. |
Forms1099Api | create1099Form | POST /1099/forms | Creates a 1099 form. |
Forms1099Api | delete1099Form | DELETE /1099/forms/{id} | Deletes a 1099 form. |
Forms1099Api | get1099Form | GET /1099/forms/{id} | Retrieves a 1099 form. |
Forms1099Api | get1099FormPdf | GET /1099/forms/{id}/pdf | Retrieves the PDF file for a single 1099 by form id. |
Forms1099Api | list1099Forms | GET /1099/forms | Retrieves a list of 1099 forms based on query parameters. |
Forms1099Api | update1099Form | PUT /1099/forms/{id} | Updates a 1099 form. |
FormsW9Api | createW9Form | POST /w9/forms | Create a W9/W4/W8 form |
FormsW9Api | deleteW9Form | DELETE /w9/forms/{id} | Delete a form |
FormsW9Api | getW9Form | GET /w9/forms/{id} | Retrieve a W9/W4/W8 form |
FormsW9Api | listW9Forms | GET /w9/forms | List W9/W4/W8 forms. |
FormsW9Api | sendW9FormEmail | POST /w9/forms/{id}/$send-email | Sends a W9 email request to a vendor/payee |
FormsW9Api | updateW9Form | PUT /w9/forms/{id} | Update a W9/W4/W8 form |
FormsW9Api | uploadW9Files | PUT /w9/forms/{id}/attachment | Upload files for a W9/W4/W8 form |
Issuers1099Api | createIssuer | POST /1099/issuers | Create an issuer |
Issuers1099Api | deleteIssuer | DELETE /1099/issuers/{id} | Delete an issuer |
Issuers1099Api | getIssuer | GET /1099/issuers/{id} | Get an issuer |
Issuers1099Api | getIssuers | GET /1099/issuers | List issuers |
Issuers1099Api | updateIssuer | PUT /1099/issuers/{id} | Update an issuer |
Jobs1099Api | getJob | GET /1099/jobs/{id} | Retrieves information about the job |
Documentation for Models
EInvoicing V1 Model Documentation
- AvalaraSDK\ModelEInvoicingV1\BadDownloadRequest
- AvalaraSDK\ModelEInvoicingV1\BadRequest
- AvalaraSDK\ModelEInvoicingV1\BatchSearch
- AvalaraSDK\ModelEInvoicingV1\BatchSearchListResponse
- AvalaraSDK\ModelEInvoicingV1\BatchSearchParticipants202Response
- AvalaraSDK\ModelEInvoicingV1\ConditionalForField
- AvalaraSDK\ModelEInvoicingV1\DataInputField
- AvalaraSDK\ModelEInvoicingV1\DataInputFieldNotUsedFor
- AvalaraSDK\ModelEInvoicingV1\DataInputFieldOptionalFor
- AvalaraSDK\ModelEInvoicingV1\DataInputFieldRequiredFor
- AvalaraSDK\ModelEInvoicingV1\DataInputFieldsResponse
- AvalaraSDK\ModelEInvoicingV1\DirectorySearchResponse
- AvalaraSDK\ModelEInvoicingV1\DirectorySearchResponseValueInner
- AvalaraSDK\ModelEInvoicingV1\DirectorySearchResponseValueInnerAddressesInner
- AvalaraSDK\ModelEInvoicingV1\DirectorySearchResponseValueInnerIdentifiersInner
- AvalaraSDK\ModelEInvoicingV1\DirectorySearchResponseValueInnerSupportedDocumentTypesInner
- AvalaraSDK\ModelEInvoicingV1\DocumentFetch
- AvalaraSDK\ModelEInvoicingV1\DocumentListResponse
- AvalaraSDK\ModelEInvoicingV1\DocumentStatusResponse
- AvalaraSDK\ModelEInvoicingV1\DocumentSubmissionError
- AvalaraSDK\ModelEInvoicingV1\DocumentSubmitResponse
- AvalaraSDK\ModelEInvoicingV1\DocumentSummary
- AvalaraSDK\ModelEInvoicingV1\ErrorResponse
- AvalaraSDK\ModelEInvoicingV1\EventId
- AvalaraSDK\ModelEInvoicingV1\EventMessage
- AvalaraSDK\ModelEInvoicingV1\EventPayload
- AvalaraSDK\ModelEInvoicingV1\EventSubscription
- AvalaraSDK\ModelEInvoicingV1\FetchDocumentsRequest
- AvalaraSDK\ModelEInvoicingV1\FetchDocumentsRequestDataInner
- AvalaraSDK\ModelEInvoicingV1\FetchDocumentsRequestMetadata
- AvalaraSDK\ModelEInvoicingV1\ForbiddenError
- AvalaraSDK\ModelEInvoicingV1\HmacSignature
- AvalaraSDK\ModelEInvoicingV1\HmacSignatureValue
- AvalaraSDK\ModelEInvoicingV1\Id
- AvalaraSDK\ModelEInvoicingV1\InputDataFormats
- AvalaraSDK\ModelEInvoicingV1\InternalServerError
- AvalaraSDK\ModelEInvoicingV1\Mandate
- AvalaraSDK\ModelEInvoicingV1\MandateDataInputField
- AvalaraSDK\ModelEInvoicingV1\MandateDataInputFieldNamespace
- AvalaraSDK\ModelEInvoicingV1\MandatesResponse
- AvalaraSDK\ModelEInvoicingV1\NotFoundError
- AvalaraSDK\ModelEInvoicingV1\NotUsedForField
- AvalaraSDK\ModelEInvoicingV1\OutputDataFormats
- AvalaraSDK\ModelEInvoicingV1\Pagination
- AvalaraSDK\ModelEInvoicingV1\RequiredWhenField
- AvalaraSDK\ModelEInvoicingV1\Signature
- AvalaraSDK\ModelEInvoicingV1\SignatureSignature
- AvalaraSDK\ModelEInvoicingV1\SignatureValue
- AvalaraSDK\ModelEInvoicingV1\SignatureValueSignature
- AvalaraSDK\ModelEInvoicingV1\StatusEvent
- AvalaraSDK\ModelEInvoicingV1\SubmitDocumentMetadata
- AvalaraSDK\ModelEInvoicingV1\SubmitInteropDocument202Response
- AvalaraSDK\ModelEInvoicingV1\SubscriptionCommon
- AvalaraSDK\ModelEInvoicingV1\SubscriptionDetail
- AvalaraSDK\ModelEInvoicingV1\SubscriptionListResponse
- AvalaraSDK\ModelEInvoicingV1\SubscriptionRegistration
- AvalaraSDK\ModelEInvoicingV1\SuccessResponse
- AvalaraSDK\ModelEInvoicingV1\WebhookInvocation
- AvalaraSDK\ModelEInvoicingV1\WebhooksErrorInfo
- AvalaraSDK\ModelEInvoicingV1\WebhooksErrorResponse
- AvalaraSDK\ModelEInvoicingV1\WorkflowIds
A1099 V2 Model Documentation
- AvalaraSDK\ModelA1099V2\Attribute
- AvalaraSDK\ModelA1099V2\AuthorizedApiRequestModel
- AvalaraSDK\ModelA1099V2\AuthorizedApiRequestV2DataModel
- AvalaraSDK\ModelA1099V2\BaseCompanyModel
- AvalaraSDK\ModelA1099V2\BaseFormListRequest
- AvalaraSDK\ModelA1099V2\BulkUpsert1099FormsRequest
- AvalaraSDK\ModelA1099V2\CompanyCreateUpdateRequestModel
- AvalaraSDK\ModelA1099V2\CompanyModel
- AvalaraSDK\ModelA1099V2\CompanyResponse
- AvalaraSDK\ModelA1099V2\CompanyResponseModel
- AvalaraSDK\ModelA1099V2\CoveredIndividualReference
- AvalaraSDK\ModelA1099V2\CoveredIndividualRequest
- AvalaraSDK\ModelA1099V2\Data
- AvalaraSDK\ModelA1099V2\ErrorModel
- AvalaraSDK\ModelA1099V2\ErrorResponse
- AvalaraSDK\ModelA1099V2\ErrorResponseErrorsInner
- AvalaraSDK\ModelA1099V2\Form1095B
- AvalaraSDK\ModelA1099V2\Form1095BList
- AvalaraSDK\ModelA1099V2\Form1095BListItem
- AvalaraSDK\ModelA1099V2\Form1095BRequest
- AvalaraSDK\ModelA1099V2\Form1099Base
- AvalaraSDK\ModelA1099V2\Form1099DivList
- AvalaraSDK\ModelA1099V2\Form1099DivListItem
- AvalaraSDK\ModelA1099V2\Form1099DivRequest
- AvalaraSDK\ModelA1099V2\Form1099DivResponse
- AvalaraSDK\ModelA1099V2\Form1099K
- AvalaraSDK\ModelA1099V2\Form1099KList
- AvalaraSDK\ModelA1099V2\Form1099KListItem
- AvalaraSDK\ModelA1099V2\Form1099KRequest
- AvalaraSDK\ModelA1099V2\Form1099List
- AvalaraSDK\ModelA1099V2\Form1099Misc
- AvalaraSDK\ModelA1099V2\Form1099MiscList
- AvalaraSDK\ModelA1099V2\Form1099MiscListItem
- AvalaraSDK\ModelA1099V2\Form1099MiscRequest
- AvalaraSDK\ModelA1099V2\Form1099MiscResponse
- AvalaraSDK\ModelA1099V2\Form1099Nec
- AvalaraSDK\ModelA1099V2\Form1099NecList
- AvalaraSDK\ModelA1099V2\Form1099NecListItem
- AvalaraSDK\ModelA1099V2\Form1099NecRequest
- AvalaraSDK\ModelA1099V2\Form1099NecResponse
- AvalaraSDK\ModelA1099V2\Form1099ProccessResult
- AvalaraSDK\ModelA1099V2\Form1099R
- AvalaraSDK\ModelA1099V2\Form1099RList
- AvalaraSDK\ModelA1099V2\Form1099RListItem
- AvalaraSDK\ModelA1099V2\Form1099RRequest
- AvalaraSDK\ModelA1099V2\Form1099StatusDetail
- AvalaraSDK\ModelA1099V2\FormRequestBase
- AvalaraSDK\ModelA1099V2\FormRequestCsvBase
- AvalaraSDK\ModelA1099V2\FormResponseBase
- AvalaraSDK\ModelA1099V2\FormSingleRequestBase
- AvalaraSDK\ModelA1099V2\Get1099Form200Response
- AvalaraSDK\ModelA1099V2\HttpValidationProblemDetails
- AvalaraSDK\ModelA1099V2\ICreateForm1099Request
- AvalaraSDK\ModelA1099V2\IUpdateForm1099Request
- AvalaraSDK\ModelA1099V2\IW9FormDataModelsOneOf
- AvalaraSDK\ModelA1099V2\IncludedBase
- AvalaraSDK\ModelA1099V2\IssuerCommand
- AvalaraSDK\ModelA1099V2\IssuerResponse
- AvalaraSDK\ModelA1099V2\JobResult
- AvalaraSDK\ModelA1099V2\Link
- AvalaraSDK\ModelA1099V2\PaginatedQueryResultModel
- AvalaraSDK\ModelA1099V2\PaginatedQueryResultModelCompanyResponse
- AvalaraSDK\ModelA1099V2\PaginatedQueryResultModelIssuerResponse
- AvalaraSDK\ModelA1099V2\PaginatedW9FormsModel
- AvalaraSDK\ModelA1099V2\ProblemDetails
- AvalaraSDK\ModelA1099V2\StateAndLocalWithholding
- AvalaraSDK\ModelA1099V2\StateAndLocalWithholdingRequest
- AvalaraSDK\ModelA1099V2\StateAndLocalWithholdingResponse
- AvalaraSDK\ModelA1099V2\StateEfileStatusDetail
- AvalaraSDK\ModelA1099V2\StateEfileStatusDetailApp
- AvalaraSDK\ModelA1099V2\StatusDetail
- AvalaraSDK\ModelA1099V2\SubstantialUsOwnerResponse
- AvalaraSDK\ModelA1099V2\Update1099Form200Response
- AvalaraSDK\ModelA1099V2\ValidationError
- AvalaraSDK\ModelA1099V2\ValidationErrorApp
- AvalaraSDK\ModelA1099V2\W4FormDataModel
- AvalaraSDK\ModelA1099V2\W4FormResponse
- AvalaraSDK\ModelA1099V2\W8BenEFormResponse
- AvalaraSDK\ModelA1099V2\W8BenESubstantialUsOwnerDataModel
- AvalaraSDK\ModelA1099V2\W8BenFormDataModel
- AvalaraSDK\ModelA1099V2\W8BenFormResponse
- AvalaraSDK\ModelA1099V2\W8BeneFormDataModel
- AvalaraSDK\ModelA1099V2\W8ImyFormDataModel
- AvalaraSDK\ModelA1099V2\W8ImyFormResponse
- AvalaraSDK\ModelA1099V2\W9FormBaseResponse
- AvalaraSDK\ModelA1099V2\W9FormDataModel
- AvalaraSDK\ModelA1099V2\W9FormResponse