Skip to main content

Invoices

Description​

The bucket exists for the purpose of storing receipts for checkouts that are contain the same information that we show after the checkout to a partners.

Upload​

The process of uploading the receipts contains two steps:

  • After FE call the endpoint POST /api/v1/venues/5/checkouts.json that is responsible for creation of new checkout (Api::V1::CheckoutsController#create) we call Cash::Checkouts::CreateInteractor that calls ::Checkouts::CreateService. In this service we have a method #_set_pdf_path that is calling after checkout creation. The method is responsible for creation of the unique PDF file name that will be used for further operations. The file name is a full public url or the future file in the S3 bucket and looks like https://<bucket name>.s3.eu-central-1.amazonaws.com/s/checkout-<id of checkout>-<date of creation>-<unique hash>.pdf. The file name is saved in the column pdf_path of the checkout.
  • After the checkout is created FE calls PUT /api/v1/venues/<venue id>/checkouts/<checkout id>/preview.json (Api::V1::CheckoutsController#update_preview) we call CheckoutReceiptPdf.generate_and_attach! for the checkout. It generates the same file name that we already have in the checkout and uploads the file that BE generates by parameters that received from FE. These parameters are saved in the checkout's column preview

Download​

To download the receipt you need to call the endpoint GET /api/v1/venues/<venue id>/checkouts/<checkout id>/preview_pdf_download (Api::V1::CheckoutsController#preview_pdf_download) that returns the JSON object with the link to the file. In this case we returning the full public url of the file

Bucket name in different environments​

  • development - be-devenvs-billing-registry
  • production - invoices.uala.it - for all countries