Apilo

Welcome to the Apilo Help Center.

[API] Creating a sales document – address selection logic

Connection with Shoper Connection with the Allegro account Connection with Erli.pl Connection to the eBay account Connection to the Amazon account Connection with OLX Connection to Empik Connection with Castorama Connection to Decathlon Connection with Black Red White Connection with Media Expert Connection with Aliexpress Connection with TikTok Shop List of inventory – accounting programs that you can connect to Apilo Connection to Hebe Connection to Morele Marketplace Connection to Ceneo.pl Connection to Kaufland DE / PL / CZ / SK / AT / FR / IT Connection to CDiscount Connection with Shopify Connection to Shopify – Authorization via Custom APP method Connection to Etsy.com Connection with InPost Fresh Connection with InPost Von Halsky Connection with IdoSell Connection with Prestashop Connection to WooCommerce Connection with ShopGold Connection to eMag Connection to RedCart Apilo Returns Connection to Gmail Connection with Labelcall Connection with Thunderbird Connection to Magento Connection with the Inpost courier Ship from Allegro, Allegro Smart, Allegro One Connection with DPD courier Connection with the GLS courier Connection with UPS courier Connection with DHL Poland courier Connection with FedEx Poland Connection with FedEx International Connection with courier Poczta Polska Connection to ShipCenter Connection to Amazon Easy Ship Connection with Orlen Paczka Connection with New Colors Connection with Eurohermes Connection to Paxy Connection with Global24 Connection with the courier Rohlig Suus Apilo Warehouse – based on an external inventory and accounting program of the ERP type Connection with the GEODIS (Pekaes) courier Connection with DPD courier (Germany) Connection with DHL (Germany) Connection with the Apaczka broker Connection with the Furgonetka.pl broker Connection to the Erli.pl broker Connection with the broker Olza Logistic Connection with the Meest Post broker Connection with the BliskaPaczka broker List of all couriers and brokers that you will connect to Apilo. Connection with wFirma.pl – invoices and receipts Connection to FakturaXL – invoices Connection with Fakturownia.pl – invoices and receipts Connection with inFakt Connection with Shoper Invoice and Warehouse Connection with iFirma.pl Connection to Subiekt GT – Sellintegro connector Connection with Subiekt GT/Nexo/Nexo Pro – integratory.pl connector Receipts – connecting a fiscal printer EAN barcodes – Barcode scanner Labels – Connecting the label printer and printing labels directly to the printer (PrintNode)

How does the system select the billing address?

Key Address Fields Used in the Process (Reference to API)

Below is described the process of automatic selection of the billing address based on available data, with references to a typical API response structure. Understanding this logic is crucial for correctly generating sales documents and interpreting system operations.

## Key Address Fields Used in the Process (Reference to API)

The system operates based on several key address fields. In the API response, these are usually JSON objects.* **`addressInvoice`**:* **For the user:** A special place to enter the address that should appear on the invoice. If you want the invoice to be sent to a different address than the delivery address or the main contact address, it should be provided here.
* **For the developer:** In the API response, this is a JSON object, e.g., `response.addressInvoice`.

```jsonr
"addressInvoice": {r
"name": "Jan Kowalski",r
"phone": "+48 500 000 000",r
"email": "jan.kowalski@apilo.com",r
"streetName": "Testowa",r
"streetNumber": "4b/12",r
"city": "Kraków",r
"zipCode": "31-154",r
"country": "PL",r
"companyTaxNumber": "937-271-51-54", // NIP if the invoice is for a companyr
"companyName": "Apilo Sp. z o.o." // Company name if the invoice is for a company
}r
```

If this object exists (is not `null`) and contains data (e.g., is not an empty object `{}`), its content is used for the invoice. This field has the highest priority.* **`addressCustomer`**:* **For the user:** The main address associated with your account or customer data. This can be your residence or company’s registered address. The system distinguishes the type of this address.
* **For the developer:** In the API response, this is a JSON object, e.g., `response.addressCustomer`.

```jsonr
"addressCustomer": {r
"name": "Jan Kowalski",r
// ... other fields as abover
"companyTaxNumber": "937-271-51-54",r
"companyName": "Apilo Sp. z o.o."r
}r
```

The logic of the invoice is based on an additional conceptual field `class` (e.g., `response.addressCustomer.class`), which categorizes the type of address:r
* `”customer”`: Standard, general customer address.
* `”house”`: Interpreted as the customer’s home address.
* `”company”`: Interpreted as the customer’s business address.* **`addressDelivery`**:* **For the user:** The address to which the ordered product or service will be delivered.
* **For the developer:** In the API response, this is a JSON object, e.g., `response.addressDelivery`.
“`json

"addressDelivery": {r
"name": "Jan Kowalski",r
// ... other fields as abover
"parcelIdExternal": "KRA32B", // May contain pickup point datar
"parcelName": "Parcel locker, ul. Testowa 12 (next to the store)"r
}r
```

 

Invoice Address Selection Logic: Step by Step (Developer’s Perspective)

According to the new guidelines, the system utilizes the `isInvoice` field (found at the main level of the API response, e.g., `response.isInvoice`) and the availability of the `addressInvoice` object to determine which address will be used on the invoice.

**Main Logic Assumptions:**

* The `response.isInvoice` field (boolean type) signals whether a specific invoice address (`addressInvoice`) should be used for the given order, or, in the absence of that, the customer’s address (`addressCustomer`).
* If `response.isInvoice` is `true` and `response.addressInvoice` exists and contains data, then `response.addressInvoice` is the invoice address.
* If `response.addressInvoice` does not exist (is `null` or empty), the invoice address becomes `response.addressCustomer`. The role of `isInvoice` in this specific case is to signal the general need for invoicing, and the system selects the best available address according to this rule.**Address Selection Steps (for the developer):**1. **Check the dedicated invoice address (`response.addressInvoice`) in the context of the `isInvoice` flag:**
* **Condition:** If the `response.isInvoice` field is `true` AND the `response.addressInvoice` object exists and contains data (e.g., is not `null` and is not an empty object `{}`).
* For example, in JavaScript:

```javascriptr
if (response.isInvoice === true && response.addressInvoice && Object.keys(response.addressInvoice).length > 0)r
```

* **Action:** The invoice address is the content of the `response.addressInvoice` object.

2. **Use the customer address (`response.addressCustomer`) as a primary or fallback:**
* **Condition:** If the above condition (using `response.addressInvoice`) is not met, meaning:
* `response.addressInvoice` does not exist or is empty (regardless of the `isInvoice` flag, if the goal is always to choose *some* address when an invoice is needed), OR
* `response.isInvoice` is `false` (in this scenario, if `isInvoice` = `false`, it means “use `addressCustomer` for the invoice”, not “do not generate an invoice” – this would require confirmation).
* **Action:** The invoice address is the content of the `response.addressCustomer` object.
* For example, in JavaScript (as part of the `else` instruction to the above `if`):

```javascriptr
else if (response.addressCustomer) {r
// Use response.addressCustomerr
}r
```

**Simplified Decision Scheme:**1. Does `response.addressInvoice` exist and contain data?
* **YES:**
* Is `response.isInvoice` `true`?
* **YES:** Use `response.addressInvoice`.
* **NO:** (Behavior not fully defined by the last description – whether to use `addressCustomer`, or not specifically invoice? Based on “data for the invoice is selected according to the isInvoice field, which determines which address should be chosen”, if `isInvoice` is `false`, then `addressInvoice` is not the “selected address”. The system probably falls back to `addressCustomer` or does not generate the invoice with those details). For consistency with the second condition, if `isInvoice` is `false`, `addressInvoice` is not used, and the system should check `addressCustomer` if an invoice is to be generated at all.
* **NO (`response.addressInvoice` is `null` or empty):**
* Use `response.addressCustomer`.

This guide has been translated using AI-powered tools.

Still need help?

Talk to a support agent