In this article you will learn how to upload receipts as PDFs to the RetailForce Cloud using the fiscal client (when using fiscalisation) and get a link for your customer to download / access the receipts.
This functionality is available from version 1.2 of the client and provides a corresponding offline capability for the digital receipt.
Attention: If you do not use fiscalisation, then the call has to be designed differently, please read article Transfer of digital receipts via the fiscal client.
In order to use this function, the Digital Receipt (full product) licence must be activated in the configuration for the respective client.
Attention: In order for the system to be able to read the metadata from the fiscal document, the fiscal document must be transmitted to the fiscal client BEFORE the following methods are called.
Use by means of FiscalClient/FiscalService
When using the FiscalClient, the following 2 methods are available for transferring digital receipts:
Method using file name
/// <summary>
/// Uploads digital receipt with digital receipt metadata.
/// </summary>
/// <param name="uniqueClientId">The client id of the client where the digital receipt should be uploaded.</param>
/// <param name="filename">The name of the file to be uploaded. The file must exist and must be readable.</param>
/// <param name="documentGuid">The document guid of the document to get the receipt meta data. Document must be transferred before to fiscalisation.</param>
/// <returns>A unique url to download the file for the customer.</returns>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="uniqueClientId"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="filename"/> is null or <see cref="string.Empty"/>.</exception>
/// <exception cref="FileNotFoundException">Thrown if given filename is not found.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="documentGuid"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="UnauthorizedAccessException"><paramref name="filename" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="IOException">An I/O error occurred while opening the file. </exception>
public string UploadDigitalReceipt(Guid uniqueClientId, string filename, Guid documentGuid)
This function allows you to upload the digital receipt using a file on the hard disk (file name).
Parameters
- uniqueClientId: the unique Id of the fiscal client.
- filename: the file name (incl. path) of the PDF file to be uploaded.
- documentGuid: the Guid of the fiscal document (Document.DocumentGuid)
Return value: URL for display.
Streaming method
/// <summary>
/// Uploads digital receipt with digital receipt metadata.
/// </summary>
/// <param name="uniqueClientId">The client id of the client where the digital receipt should be uploaded.</param>
/// <param name="file">The stream of the file to be uploaded.</param>
/// <param name="documentGuid">The document guid of the document to get the receipt meta data. Document must be transferred before to fiscalisation.</param>
/// <returns>A unique url to download the file for the customer.</returns>
/// <remarks>You can only use documents from the actual day.</remarks>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="uniqueClientId"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="file"/> is set to null.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="documentGuid"/> is set to <see cref="Guid.Empty"/>.</exception>
public string UploadDigitalReceipt(Guid uniqueClientId, Stream file, Guid documentGuid)
With this function you can upload the digital receipt by transferring a filestream (or streams).
Parameters
- uniqueClientId: the unique Id of the fiscal client.
- file: the stream with the content of the PDF file (stream must be at the beginning)
- documentGuid: the Guid of the fiscal document (Document.DocumentGuid)
Return value: URL for display.
Usage via nuget implementation
When using the direct implementation of the Fiskaclient (TrustedFiscalModule) with nuget, only one method with FileStream is available:
/// <summary>
/// Upload digital receipt (if proper license exists). Only in combination with fiscalisation.
/// </summary>
/// <param name="file">The file to upload.</param>
/// <param name="documentGuid">The document guid of the document to get the receipt meta data. Document must be transferred before to fiscalisation.</param>
/// <returns>An url to request the file in the cloud.</returns>
/// <remarks>You can only use documents from the actual day.</remarks>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="file"/> is set to null.</exception>
/// <exception cref="ArgumentNullException">Thrown if parameter <paramref name="documentGuid"/> is set to <see cref="Guid.Empty"/>.</exception>
/// <exception cref="KeyNotFoundException">Thrown if the given documentGuid does not found a document in the document store.</exception>
public string UploadDigitalReceipt(Stream file, Guid documentGuid)
With this function you can upload the digital receipt by transferring a filestream (or streams).
Parameters
- file: the stream with the content of the PDF file (stream must be at the beginning)
- documentGuid: The Guid of the fiscal document (Document.DocumentGuid)
Return value: URL for display.
Comments
0 comments
Please sign in to leave a comment.