PHPackages                             tilta-io/tilta-php-sdk - 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. [API Development](/categories/api)
4. /
5. tilta-io/tilta-php-sdk

ActiveLibrary[API Development](/categories/api)

tilta-io/tilta-php-sdk
======================

SDK PHP for Tilta API

2.0.1(1y ago)07.2k2MITPHPPHP ^8.1

Since Jul 10Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/tilta-io/tilta-php-sdk)[ Packagist](https://packagist.org/packages/tilta-io/tilta-php-sdk)[ Docs](https://www.tilta.io/)[ RSS](/packages/tilta-io-tilta-php-sdk/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (12)Used By (2)

Usage
-----

[](#usage)

### General usage

[](#general-usage)

For every request there is a

- request service (instance of `\Tilta\Sdk\Service\Request\AbstractRequest`) Knows anything about the request itself (url, method, authorization)
- request model (instance of `\Tilta\Sdk\Model\Response\AbstractRequestModel`) Knows anything about the parameters of the request, and acts as DTO to submit the data to the request service
- response model (instance of `\Tilta\Sdk\Model\Response\AbstractResponseModel`) Knows anything about the response data, and acts as DTO to receives the data from the request service Note: in some cases there is not response. Just a `true` got returned from the RequestService if the request was successful.

### Get a `\Tilta\Sdk\HttpClient\TiltaClient`-instance

[](#get-a-tiltasdkhttpclienttiltaclient-instance)

Use the `\Tilta\Sdk\Util\TiltaClientFactory` to get a new instance.

The factory will store the generated `TiltaClient`-instance in a static variable. So it will not produce a new request, if you request a new `TiltaClient`-instance.

```
$isSandbox = true;
$tiltaClient = \Tilta\Sdk\Util\TiltaClientFactory::getClientInstance('YOUR_TOKEN', $isSandbox);
```

Provide a boolean as second parameter to define if the request goes against the sandbox or not.

### Get an instance of a request service

[](#get-an-instance-of-a-request-service)

You can simply create a new instance of the corresponding service.

*Example*:

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $tiltaClient **/

$requestService = new \Tilta\Sdk\Service\Request\RequestServiceClass($tiltaClient);
```

You must not provide the `TiltaClient` via the constructor, but you should set it, before calling `execute` on the request service.

*Example*:

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $tiltaClient **/

$requestService = new \Tilta\Sdk\Service\Request\RequestServiceClass();
// [...]
$requestService->setClient($tiltaClient);
// [...]
$requestService->execute(...);
```

### Models

[](#models)

#### Request models: Validation

[](#request-models-validation)

Every field of a request model (not response models) will be validated automatically, during calling its setter. If you provide a wrong value or in an invalid format, an `\Tilta\Sdk\Exception\Validation\InvalidFieldException` will be thrown.

You can disable this automatic validation, by calling the method `setValidateOnSet` on the model:

```
/** @var \Tilta\Sdk\Model\Request\AbstractRequestModel $requestModel */

$requestModel->setValidateOnSet(false);
```

The model got validate at least by the request service, to make sure that all data has been provided, and you will get no validation exception through the gateway.

#### Response models

[](#response-models)

Every response model is set to be read-only.

You can not set any fields on this model. You will get a `BadMethodCallException`.

### Requests

[](#requests)

This documentation should not explain the whole usage of each request. It should only show the main information about each request, and the main usage.

Please have a look into the corresponding documentation of each API Request.

#### GetBuyerAuthTokenRequest

[](#getbuyerauthtokenrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-auth-buyer-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Buyer\\GetBuyerAuthTokenRequest](src/Service/Request/Buyer/GetBuyerAuthTokenRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Buyer\\GetBuyerAuthTokenRequestModel](src/Model/Request/Buyer/GetBuyerAuthTokenRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Buyer\\GetBuyerAuthTokenResponseModel](src/Model/Response/Buyer/GetBuyerAuthTokenResponseModel.php)Use this service to generate JWT token for the buyer, so he can use the buyer-onboarding requests.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$tokenRequestService = new \Tilta\Sdk\Service\Request\Buyer\GetBuyerAuthTokenRequest($client);

$requestModel = new \Tilta\Sdk\Model\Request\Buyer\GetBuyerAuthTokenRequestModel('EXTERNAL-MERCHANT-ID');

/** @var \Tilta\Sdk\Model\Response\Buyer\GetBuyerAuthTokenResponseModel */
$responseModel = $tokenRequestService->execute($requestModel);
$accessToken = $responseModel->getBuyerAuthToken();
```

#### GetBuyerDetailsRequest

[](#getbuyerdetailsrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Buyer\\GetBuyerDetailsRequest](src/Service/Request/Buyer/GetBuyerDetailsRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Buyer\\GetBuyerDetailsRequestModel](src/Model/Request/Buyer/GetBuyerDetailsRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Buyer](src/Model/Buyer.php)Use this service to fetch a buyer from the gateway by its external-id (of the merchant)

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$tokenRequestService = new \Tilta\Sdk\Service\Request\Buyer\GetBuyerDetailsRequest($client);

$requestModel = new \Tilta\Sdk\Model\Request\Buyer\GetBuyerDetailsRequestModel('EXTERNAL-MERCHANT-ID');

/** @var \Tilta\Sdk\Model\Buyer */
$responseModel = $tokenRequestService->execute($requestModel);
$externalId = $responseModel->getExternalId();
$legalName = $responseModel->getLegalName();
[...]
```

#### GetBuyerListRequest

[](#getbuyerlistrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers)Request service[\\Tilta\\Sdk\\Service\\Request\\Buyer\\GetBuyerListRequest](src/Service/Request/Buyer/GetBuyerListRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Buyer\\GetBuyersListRequestModel](src/Model/Request/Buyer/GetBuyersListRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Buyer\\GetBuyersListResponseModel](src/Model/Response/Buyer/GetBuyersListResponseModel.php)Use this service to get all buyers. Use `limit` &amp; `offset` to navigate through the pages.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$tokenRequestService = new \Tilta\Sdk\Service\Request\Buyer\GetBuyerListRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Buyer\GetBuyersListRequestModel())
    // optional parameters
    ->setLimit(10)
    ->setOffset(0);

/** @var \Tilta\Sdk\Model\Response\Buyer\GetBuyersListResponseModel */
$responseModel = $tokenRequestService->execute($requestModel);
$limit = $responseModel->getLimit();
$limit = $responseModel->getOffset();
$limit = $responseModel->getTotal();
/** @var \Tilta\Sdk\Model\Buyer[] $items */
$items = $responseModel->getItems();
$legalNameOfCompany1 = $items[0]->getLegalName();
$legalNameOfCompany2 = $items[1]->getLegalName();
[...]
```

#### CreateBuyerRequest

[](#createbuyerrequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-buyers)Request service[\\Tilta\\Sdk\\Service\\Request\\Buyer\\CreateBuyerRequest](src/Service/Request/Buyer/CreateBuyerRequest.php)Request model[\\Tilta\\Sdk\\Model\\Buyer](src/Model/Buyer.php)Response model`true`Use this service to create a new buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Buyer\CreateBuyerRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Buyer())
    ->setExternalId('EXTERNAL_MERCHANT_ID')
    ->setTradingName('Trading name')
    ->setLegalForm('DE_GMBH')
    ->setLegalName('Legal name')
    ->setRegisteredAt((new DateTime())->setDate(2000, 2, 12))
    ->setIncorporatedAt((new DateTime())->setDate(2002, 5, 30))
    ->setContactPersons(new \Tilta\Sdk\Model\ContactPerson())
    ->setBusinessIdentifiers([
        new \Tilta\Sdk\Model\Buyer\BusinessIdentifier()
    ])
    ->setBusinessAddress(new \Tilta\Sdk\Model\Address())
    ->setCustomData([
        'custom-key' => 'custom-value1',
        'custom-key2' => 'custom-value2'
    ]);

/** @var boolean $response */
$response = $requestService->execute($requestModel); // true if successfully
```

#### UpdateBuyerRequest

[](#updatebuyerrequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-buyers-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Buyer\\UpdateBuyerRequest](src/Service/Request/Buyer/UpdateBuyerRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Buyer\\UpdateBuyerRequestModel](src/Model/Request/Buyer/UpdateBuyerRequestModel.php)Response model`true`Use this service to update buyers data.

You must not provide all buyers data, just these data, which you want to update. If you want to update a sub-object ( e.g. `contactPersons` or `businessAddress`), you have to provide all data (of the sub-object), to prevent validation issues. This behaviour may change in the future.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Buyer\UpdateBuyerRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Buyer\UpdateBuyerRequestModel('EXTERNAL_MERCHANT_ID'))
    // same methods as in the \Tilta\Sdk\Model\Buyer model. You must provide all data, just these data, which should be updated.
    ->setTradingName('Trading name')
    ->setCustomData([
        'custom-key' => 'custom-value1',
        'custom-key2' => 'custom-value2'
    ]);

/** @var boolean $response */
$response = $requestService->execute($requestModel); // true if successfully
```

#### CreateFacilityRequest

[](#createfacilityrequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-buyers-external-id-facility)Request service[\\Tilta\\Sdk\\Service\\Request\\Facility\\CreateFacilityRequest](src/Service/Request/Facility/CreateFacilityRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Facility\\CreateFacilityRequestModel](src/Model/Request/Facility/CreateFacilityRequestModel.php)Response model`true`Use this service to create a new facility for a buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Facility\CreateFacilityRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Facility\CreateFacilityRequestModel('EXTERNAL_MERCHANT_ID'));

/** @var boolean $response */
$response = $requestService->execute($requestModel); // true if successfully
```

#### GetFacilityRequest

[](#getfacilityrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id-facility)Request service[\\Tilta\\Sdk\\Service\\Request\\Facility\\GetFacilityRequest](src/Service/Request/Facility/GetFacilityRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Facility\\GetFacilityRequestModel](src/Model/Request/Facility/GetFacilityRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Facility\\GetFacilityResponseModel](src/Model/Response/Facility/GetFacilityResponseModel.php)Use this service to get the active facility for a buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Facility\GetFacilityRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Facility\GetFacilityRequestModel('EXTERNAL_MERCHANT_ID'));

/** @var \Tilta\Sdk\Model\Response\Facility\GetFacilityResponseModel $response */
$response = $requestService->execute($requestModel);
$response->getBuyerExternalId();
$response->getAvailableAmount();
[...]
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\Facility\NoActiveFacilityFoundException`if the buyer does not have an active facility`Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the buyer does not exist.#### CreateOrderRequest

[](#createorderrequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-orders)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\CreateOrderRequest](src/Service/Request/Order/CreateOrderRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\CreateOrderRequestModel](src/Model/Request/Order/CreateOrderRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Order](src/Model/Order.php)Use this service to create a new order for a buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\CreateOrderRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\CreateOrderRequestModel())
            ->setOrderExternalId('order-external-id')
            ->setBuyerExternalId('buyer-external-id')
            ->setMerchantExternalId('merchant-external-id')
            ->setAmount(new \Tilta\Sdk\Model\Amount())
            ->setComment('order-comment')
            ->setOrderedAt((new DateTime()))
            ->setPaymentMethod(\Tilta\Sdk\Enum\PaymentMethodEnum::TRANSFER)
            ->setPaymentTerm(\Tilta\Sdk\Enum\PaymentTermEnum::BNPL30)
            ->setDeliveryAddress(new \Tilta\Sdk\Model\Address()))
            ->setLineItems([
                new \Tilta\Sdk\Model\Order\LineItem(),
                new \Tilta\Sdk\Model\Order\LineItem(),
                new \Tilta\Sdk\Model\Order\LineItem(),
            ]);

/** @var \Tilta\Sdk\Model\Order $response */
$response = $requestService->execute($requestModel);
$orderStatus = $response->getStatus();
[...]
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the buyer does not exist.`\Tilta\Sdk\Exception\GatewayException\Facility\NoActiveFacilityFoundException`if the buyer does not have an active facility.`\Tilta\Sdk\Exception\GatewayException\Facility\FacilityExceededException`if the buyer have an active facility but the order would exceed the limit.`\Tilta\Sdk\Exception\GatewayException\NotFoundException\MerchantNotFoundException`if the provided merchant does not exist.#### GetOrderDetailsRequest

[](#getorderdetailsrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-orders-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\GetOrderDetailsRequest](src/Service/Request/Order/GetOrderDetailsRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\GetOrderDetailsRequestModel](src/Model/Request/Order/GetOrderDetailsRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Order](src/Model/Order.php)Use this service to fetch order by the external-id.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\GetOrderDetailsRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\GetOrderDetailsRequestModel('order-external-id'));

/** @var \Tilta\Sdk\Model\Order $response */
$response = $requestService->execute($requestModel);
$externalId = $response->getOrderExternalId();
$orderStatus = $response->getStatus();
[...]
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\OrderNotFoundException`if the order does not exist.#### GetOrderListRequest

[](#getorderlistrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-orders)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\GetOrderListRequest](src/Service/Request/Order/GetOrderListRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\GetOrderListRequestModel](src/Model/Request/Order/GetOrderListRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Order\\GetOrderListResponseModel](src/Model/Response/Order/GetOrderListResponseModel.php)Use this service to fetch all orders.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\GetOrderListRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\GetOrderListRequestModel())
    // optional for pagination:
    ->setOffset(150)
    ->setLimit(50)
    // optional search-parameters
    ->setMerchantExternalId('merchant-external-id')
    ->setPaymentMethod(\Tilta\Sdk\Enum\PaymentMethodEnum::TRANSFER)
    ->setPaymentTerm(\Tilta\Sdk\Enum\PaymentTermEnum::BNPL30);

/** @var \Tilta\Sdk\Model\Response\Order\GetOrderListResponseModel $response */
$response = $requestService->execute($requestModel);
$totalItemCount = $response->getTotal();
/** @var Tilta\Sdk\Model\Order[] $items */
$items = $response->getItems();
[...]
```

#### CancelOrderRequest

[](#cancelorderrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-orders-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\CancelOrderRequest](src/Service/Request/Order/CancelOrderRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\CancelOrderRequestModel](src/Model/Request/Order/CancelOrderRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Order](src/Model/Order.php)Use this service to cancel the order (if it hasn't been invoiced yet).

**Please note:** If the request was successful, an order-object is returned, instead of a boolean!

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\CancelOrderRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\CancelOrderRequestModel('order-external-id'));

/** @var \Tilta\Sdk\Model\Order $response */
$response = $requestService->execute($requestModel);
$externalId = $response->getOrderExternalId();
$response->getStatus() === \Tilta\Sdk\Enum\OrderStatusEnum::CANCELED; // true
[...]
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\OrderNotFoundException`if the order does not exist.`\Tilta\Sdk\Exception\GatewayException\NotFoundException\OrderIsCanceledException`if the order has been already canceled.#### CancelOrderRequest

[](#cancelorderrequest-1)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id-orders)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\GetOrderListForBuyerRequest](src/Service/Request/Order/GetOrderListForBuyerRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\GetOrderListForBuyerRequestModel](src/Model/Request/Order/GetOrderListForBuyerRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Order\\GetOrderListForBuyerResponseModel](src/Model/Response/Order/GetOrderListForBuyerResponseModel.php)Use this service to fetch all orders for given buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\GetOrderListForBuyerRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\GetOrderListForBuyerRequestModel('buyer-external-id'));

/** @var \Tilta\Sdk\Model\Response\Order\GetOrderListForBuyerResponseModel $response */
$response = $requestService->execute($requestModel);
/** @var \Tilta\Sdk\Model\Order[] $items */
$items = $response->getItems();
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.#### GetPaymentTermsRequest

[](#getpaymenttermsrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id-payment-terms)Request service[\\Tilta\\Sdk\\Service\\Request\\PaymentTerm\\GetPaymentTermsRequest](src/Service/Request/PaymentTerm/GetPaymentTermsRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\PaymentTerm\\GetPaymentTermsRequestModel](src/Model/Request/PaymentTerm/GetPaymentTermsRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\PaymentTerm\\GetPaymentTermsResponseModel](src/Model/Response/PaymentTerm/GetPaymentTermsResponseModel.php)Use this service to get the payment terms for an order, which would/may be placed.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\GetPaymentTermsRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\PaymentTerm\GetPaymentTermsRequestModel())
    ->setMerchantExternalId('merchant-external-id')
    ->setBuyerExternalId('buyer-external-id')
    ->setAmount(new \Tilta\Sdk\Model\Amount());

/** @var \Tilta\Sdk\Model\Response\PaymentTerm\GetPaymentTermsResponseModel $response */
$response = $requestService->execute($requestModel);
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.`\Tilta\Sdk\Exception\GatewayException\NotFoundException\MerchantNotFoundException`if the given merchant does not exist.`\Tilta\Sdk\Exception\GatewayException\Facility\FacilityExceededException`if the buyer have an active facility but the order would exceed the limit.#### AddOrdersToBuyerRequest

[](#addorderstobuyerrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id-orders)Request service[\\Tilta\\Sdk\\Service\\Request\\Order\\AddOrdersToBuyerRequest](src/Service/Request/Order/AddOrdersToBuyerRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Order\\AddOrdersToBuyerRequestModel](src/Model/Request/Order/AddOrdersToBuyerRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Order\\AddOrdersToBuyerResponseModel](src/Model/Response/Order/AddOrdersToBuyerResponseModel.php)Use this service to add existing orders, which are not processed by Tilta, to the buyer debtor.

**Please note**: The `ExistingOrder`-Model is just a subclass of the `Order`-Model. The difference is, that you can not set the `buyerExternalId` for the order, because this value has to be set on the request-model (once). So please make sure that you only provide orders, for one single buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Order\AddOrdersToBuyerRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Order\AddOrdersToBuyerRequestModel('buyer-external-id'))
    ->setItems([
        new \Tilta\Sdk\Model\Request\Order\AddOrdersToBuyer\ExistingOrder('oder-id-1'),
        new \Tilta\Sdk\Model\Request\Order\AddOrdersToBuyer\ExistingOrder('oder-id-2'),
        new \Tilta\Sdk\Model\Request\Order\AddOrdersToBuyer\ExistingOrder('oder-id-3')
    ])
    ->addOrderItem(new \Tilta\Sdk\Model\Request\Order\AddOrdersToBuyer\ExistingOrder('oder-id-4'));

/** @var \Tilta\Sdk\Model\Response\Order\AddOrdersToBuyerResponseModel $response */
$response = $requestService->execute($requestModel);
/** @var \Tilta\Sdk\Model\Order[] $items */
$items = $response->getItems();
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.`\Tilta\Sdk\Exception\GatewayException\NotFoundException\MerchantNotFoundException`if the given merchant for at least one order does not exist.#### CreateInvoiceRequest

[](#createinvoicerequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-invoices)Request service[\\Tilta\\Sdk\\Service\\Request\\Invoice\\CreateInvoiceRequest](src/Service/Request/Invoice/CreateInvoiceRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Invoice\\CreateInvoiceRequestModel](src/Model/Request/Invoice/CreateInvoiceRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Invoice](src/Model/Invoice.php)Use this service to create a new invoice for (multiple) orders.

**Please note:** In most cases, the `invoice_number` is the same as the `external_id`. The `invoice_number` is the official printed number on the invoice document, while the `external_id` is the internal identifier of the invoice in your system. You may submit the `invoice_number` as the `external_id` as well if you don't want to submit a separate number.

However, please remember that you always have to use the `external_id` in future requests as reference to the invoice. So if you are using the `invoice_number` as the `external_id`, you have to submit the "invoice number" as the `external_id`.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Invoice\CreateInvoiceRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Invoice\CreateInvoiceRequestModel())
    ->setInvoiceExternalId('invoice-external-id')
    ->setInvoiceNumber('invoice-number')
    ->setOrderExternalIds(['order-external-id-1', 'order-external-id-2']) // just provide an array with one value, if you create an invoice for a single order.
    ->setAmount(new \Tilta\Sdk\Model\Amount())
    ->setBillingAddress(new \Tilta\Sdk\Model\Address())
    ->setLineItems([
      new \Tilta\Sdk\Model\Order\LineItem(),
      new \Tilta\Sdk\Model\Order\LineItem(),
      new \Tilta\Sdk\Model\Order\LineItem(),
      new \Tilta\Sdk\Model\Order\LineItem(),
    ]);

/** @var \Tilta\Sdk\Model\Invoice $response */
$response = $requestService->execute($requestModel);
```

**Expected exceptions thrown by service**

TODOTODOTODOTODO#### GetInvoiceRequest

[](#getinvoicerequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-invoices-external-id)Request service[\\Tilta\\Sdk\\Service\\Request\\Invoice\\GetInvoiceRequest](src/Service/Request/Invoice/GetInvoiceRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Invoice\\GetInvoiceRequestModel](src/Model/Request/Invoice/GetInvoiceRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Invoice](src/Model/Invoice.php)Use this service to fetch a single invoice.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Invoice\GetInvoiceRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Invoice\GetInvoiceRequestModel('invoice-external-id'));

/** @var \Tilta\Sdk\Model\Invoice $response */
$response = $requestService->execute($requestModel);
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\InvoiceNotFoundException`if the invoice does not exist.#### GetInvoiceRequestModel

[](#getinvoicerequestmodel)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-invoices) [Link (Buyers)](https://docs.tilta.io/reference/get_v1-buyers-external-id-invoices)Request service[\\Tilta\\Sdk\\Service\\Request\\Invoice\\GetInvoiceListRequest](src/Service/Request/Invoice/GetInvoiceListRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Invoice\\GetInvoiceRequestModel](src/Model/Request/Invoice/GetInvoiceRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Invoice\\GetInvoiceListResponseModel](src/Model/Response/Invoice/GetInvoiceListResponseModel.php)Use this service to fetch all invoices. Optional: You can filter by the buyer-id

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Invoice\GetInvoiceListRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\Invoice\GetInvoiceListRequestModel())
    ->setMerchantExternalId('merchant-external-id')
    ->setBuyerExternalId('buyer-external-id') // optional
    // optional for pagination:
    ->setOffset(150)
    ->setLimit(50);

/** @var \Tilta\Sdk\Model\Response\Invoice\GetInvoiceListResponseModel $response */
$response = $requestService->execute($requestModel);
$totalItemCount = $response->getTotal();
/** @var \Tilta\Sdk\Model\Invoice[] $items */
$items = $response->getItems();
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\MerchantNotFoundException`if the given merchant does not exist.#### CreateCreditNoteRequest

[](#createcreditnoterequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-buyers-external-id-creditnotes)Request service[\\Tilta\\Sdk\\Service\\Request\\CreditNote\\CreateCreditNoteRequest](src/Service/Request/CreditNote/CreateCreditNoteRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\CreditNote\\CreateCreditNoteRequestModel](src/Model/Request/CreditNote/CreateCreditNoteRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\CreditNote](src/Model/CreditNote.php)Use this service to create a new credit note for a buyer

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\CreditNote\CreateCreditNoteRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\CreditNote\CreateCreditNoteRequestModel())
    ->setCreditNoteExternalId('credit-note-external-id')
    ->setBuyerExternalId('buyer-external-id')
    ->setInvoicedAt(new DateTime())
    ->setAmount(new \Tilta\Sdk\Model\Amount())
    ->setBillingAddress(new \Tilta\Sdk\Model\Address())
    ->setLineItems([
        new \Tilta\Sdk\Model\Order\LineItem(),
        new \Tilta\Sdk\Model\Order\LineItem(),
        new \Tilta\Sdk\Model\Order\LineItem(),
    ])
    ->setOrderExternalIds(['order-external-id-1', 'order-external-id-2']); // just provide an array with one value, if you create a credit-node for a single order.

/** @var \Tilta\Sdk\Model\CreditNote $response */
$response = $requestService->execute($requestModel);
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.`\Tilta\Sdk\Exception\GatewayException\InvoiceForCreditNoteNotFound`if order(s) got not found or order(s) does not have an invoice.#### CreateSepaMandateRequest

[](#createsepamandaterequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-buyers-external-id-mandates)Request service[\\Tilta\\Sdk\\Service\\Request\\SepaMandate\\GetSepaMandateListRequest](src/Service/Request/SepaMandate/GetSepaMandateListRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\SepaMandate\\GetSepaMandateListRequestModel](src/Model/Request/SepaMandate/GetSepaMandateListRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\SepaMandate\\GetSepaMandateListResponseModel](src/Model/Response/SepaMandate/GetSepaMandateListResponseModel.php)Use this service to list all sepa mandates of a buyer.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\SepaMandate\GetSepaMandateListRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\SepaMandate\GetSepaMandateListRequestModel('buyer-external-id'))
    // optional for pagination:
    ->setOffset(150)
    ->setLimit(50)

/** @var \Tilta\Sdk\Model\Response\SepaMandate\GetSepaMandateListResponseModel $response */
$response = $requestService->execute($requestModel);
/** @var \Tilta\Sdk\Model\Response\SepaMandate[] $items */
$items = $response->getItems()
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.`\Tilta\Sdk\Exception\GatewayException\SepaMandate\DuplicateSepaMandateException`if a SEPA mandate with the same Iban does already exist`\Tilta\Sdk\Exception\GatewayException\SepaMandate\InvalidIbanException`if the iban is not valid#### GetSepaMandateListRequest

[](#getsepamandatelistrequest)

Api documentation[Link](https://docs.tilta.io/reference/post_v1-buyers-external-id-mandates)Request service[\\Tilta\\Sdk\\Service\\Request\\SepaMandate\\CreateSepaMandateRequest](src/Service/Request/SepaMandate/CreateSepaMandateRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\SepaMandate\\CreateSepaMandateRequestModel](src/Model/Request/SepaMandate/CreateSepaMandateRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\SepaMandate](src/Model/Response/SepaMandate.php)Use this service to create a SEPA mandate for the given buyer

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\SepaMandate\CreateSepaMandateRequest($client);

$requestModel = (new \Tilta\Sdk\Model\Request\SepaMandate\CreateSepaMandateRequestModel('buyer-external-id'))
    ->setIban('DE123456789987654')

/** @var \Tilta\Sdk\Model\Response\SepaMandate $response */
$response = $requestService->execute($requestModel);
$response->getIban();
$response->getMandateId();
```

**Expected exceptions thrown by service**

`\Tilta\Sdk\Exception\GatewayException\NotFoundException\BuyerNotFoundException`if the given buyer does not exist.#### GetLegalFormsRequest

[](#getlegalformsrequest)

Api documentation[Link](https://docs.tilta.io/reference/get_v1-legal-forms-country-code)Request service[\\Tilta\\Sdk\\Service\\Request\\Util\\GetLegalFormsRequest](src/Service/Request/Util/GetLegalFormsRequest.php)Request model[\\Tilta\\Sdk\\Model\\Request\\Util\\GetLegalFormsRequestModel](src/Model/Request/Util/GetLegalFormsRequestModel.php)Response model[\\Tilta\\Sdk\\Model\\Response\\Util\\GetLegalFormsResponseModel](src/Model/Response/Util/GetLegalFormsResponseModel.php)Use this service to fetch all legal forms, which would be available for given country.

**Usage**

```
/** @var \Tilta\Sdk\HttpClient\TiltaClient $client */
$requestService = new \Tilta\Sdk\Service\Request\Util\GetLegalFormsRequest($client);

// DE = requested country
$requestModel = (new \Tilta\Sdk\Model\Request\Util\GetLegalFormsRequestModel('DE'));

/** @var \Tilta\Sdk\Model\Response\Util\GetLegalFormsResponseModel $response */
$response = $requestService->execute($requestModel);

/* $items would be key-value pairs:
 *  e.g. [
 *      'DE_GMBH' => 'Gesellschaft mit beschränkter Haftung',
 *      'DE_AG' => 'Aktiengesellschaft'
 * ]
 */
$items = $response->getItems();
$response->getDisplayName('DE'); // = Gesellschaft mit beschränkter Haftung
```

**Expected exceptions thrown by service**

**Please note:** This service will handle automatically the error if the country code is unknown/invalid. It will return empty item-list.

### Additional features

[](#additional-features)

#### Logging

[](#logging)

you can enable logging all API Requests. (maybe we will log other things in the future, too).

You just have to give us an instance of `\Psr\Log\LoggerInterface`. This could be a logger of the popular [monolog/monolog](https://github.com/Seldaek/monolog) package.

Please note, you can only pass a logger of the mentioned interface. If you have a custom logger, you have to implement the interface. Do not forget to install the package [psr/log](https://github.com/php-fig/log).

**Please note:** you should not set a debug-logger in production, because this will log all requests (successful and failed). If you only set a ERROR-Handler it will only log all failed requests.

Example:

```
$logFile = '/path/to/your/logfile.log';
$logger = new \Monolog\Logger('name-for-the-logger');

$handlerDebug = new \Monolog\Handler\StreamHandler('/path/to/your/log-file.debug.log', LogLevel::DEBUG);
$logger->pushHandler($handlerDebug);
$handlerError = new \Monolog\Handler\StreamHandler('/path/to/your/log-file.error.log', LogLevel::ERROR);
$logger->pushHandler($handlerError);

\Tilta\Sdk\Util\Logging::setPsr3Logger($logger);
// call this if you want to log the request-headers too
\Tilta\Sdk\Util\Logging::setLogHeaders(true);
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance57

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~115 days

Total

7

Last Release

428d ago

Major Versions

1.0.0 → 2.0.02024-11-28

PHP version history (2 changes)1.0.0-alpha1PHP ^7.4 || ^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a90bcfb9daf0fd7cb93ef1449e706f86ef33f0ad304f5305aa395b59da70e75?d=identicon)[webidea](/maintainers/webidea)

![](https://www.gravatar.com/avatar/a4a933670908b9f2a9e5f037708987745fc71e606e82769747cef48fb4363650?d=identicon)[Tilta.Engineering](/maintainers/Tilta.Engineering)

---

Top Contributors

[![rommelfreddy](https://avatars.githubusercontent.com/u/15031079?v=4)](https://github.com/rommelfreddy "rommelfreddy (127 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tilta-io-tilta-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/tilta-io-tilta-php-sdk/health.svg)](https://phpackages.com/packages/tilta-io-tilta-php-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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