This module provides functionality to retrieve official PDF documents generated by the WeArePlanet backend.
The module follows the Domain-Driven Design (DDD) and Clean Architecture principles:
- Domain Layer (
src/Document): Contains theRenderedDocumententity and theDocumentGatewayInterfaceandDocumentService. - Infrastructure Layer (
src/Sdk/WebServiceAPIV1): Contains theDocumentGatewayimplementation that interacts with the SDK.
- Retrieve Invoice: Get the rendered invoice PDF for a transaction.
- Retrieve Packing Slip: Get the packing slip PDF for a transaction.
- Retrieve Refund Credit Note: Get the credit note PDF for a specific refund.
Use the DocumentService to retrieve documents. You will need the Space ID and the Transaction ID (or Refund ID).
// Instantiate DocumentService (usually via DI)
$documentService = new DocumentService($documentGateway);
// Get Invoice
$invoice = $documentService->getInvoice($spaceId, $transactionId);
file_put_contents('invoice.pdf', $invoice->data);
// Get Packing Slip
$packingSlip = $documentService->getPackingSlip($spaceId, $transactionId);
file_put_contents('packing-slip.pdf', $packingSlip->data);See example/download_documents.php for a complete runnable script.