To generate a locally compliant invoice, credit note, or receipt after reporting a transaction, use the following invoicing endpoint along with the reporting transaction identifier you previously requested, with an empty request body:

POST /invoicing/v2/invoices/transaction/{transaction_id}

It will return a document synchronously, formatted as a base64 string, as a PDF, and an HTML file:

{
    "status": "success",
    "data": {
        "id": "3dfc3fb19adc4c1abac4312e734942d6",
        "base64_pdf": “BASE64 DATA”,
        "base64_html": “BASE64 DATA”, 
        "created_at": "2021-08-19T13:57:20.9981236+00:00"
    },
    "message": "Invoice was successfully generated.",
    "errors": null
}

Invoice example:

Marketplace use case (third-party invoicing)

When it comes to marketplaces, a common use case is to issue a reported transaction to the customer on behalf of the underlying marketplace participant.

For eg., Let's assume that Supplier Company ABC is a marketplace participant, rendering a service to a B2C customer (Zlatan Orban) through Marketplace AB, and the marketplace wants to report transactions to the Hungarian tax authorities and issue invoices on behalf of the supplier to the customer.

This is the process that needs to take palace:

    1. Report a B2C transaction following instructions in Reporting Transaction section, including the Supplier Company XYZ and B2C customer (Zlatan Orban) as the counterparts after they were onboarded to Fonoa
    1. Once the transaction was reported, retrieve the transaction id - this will then be used in order to generate an invoice on behalf of the supplier
    1. Generate the reported invoice on behalf of the supplier - with Marketplace AB as the issuer of the invoice for the underlying reported transaction

Now lets’ deep dive into step 3.
Here is the example of the JSON request:

POST /onboarding/v2/companies

{
    "meta": {
        "country_code": "hu",
        "language_code": "hu",
        "external_id": "VendorHU01"
    },
    "legal_name": "Marketplace AB",
    "company_number": "21588017-2-45",
    "address": {
      "country_code":"hu",
      "address_line_1":"Salétrom u. 4",
      "city":"Budapest",
      "postal_code":"1053"
    },
    "tax_information": {
        "tax_number": "21588017-2-45",
        "regime": "VAT"
    }
}

Once the company is successfully onboarded, you can generate documents mentioning the issuer.

Use Request an invoice endpoint to execute this step.

Note that the id parameter in the below request should correspond to the transaction id that was previously reported.

POST: https://api-demo.fonoa.com/invoicing/v2/invoices/transaction/31add54ef0af4983acf5e741ef12909f
Whereas, the request body contains the issuer id (identifier of the issuer company):

{
  "issuer": {
    "id": "31add54ef0af4983acf5e741ef12909f"
     }
}

Example of the response JSON:

{
    "status": "success",
    "data": {
        "id": "75867e506e5745ddb80af369392b224d",
        "base64_pdf": “BASE64 DATA”,
        "base64_html": ”BASE64 DATA”,
        "created_at": "2021-08-19T13:57:20.9981236+00:00"
    },
    "message": "Invoice was successfully generated.",
    "errors": null
}