Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.37 KB

File metadata and controls

37 lines (24 loc) · 1.37 KB

Document Management

This module provides functionality to retrieve official PDF documents generated by the WeArePlanet backend.

Application Structure

The module follows the Domain-Driven Design (DDD) and Clean Architecture principles:

  • Domain Layer (src/Document): Contains the RenderedDocument entity and the DocumentGatewayInterface and DocumentService.
  • Infrastructure Layer (src/Sdk/WebServiceAPIV1): Contains the DocumentGateway implementation that interacts with the SDK.

Features

  • 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.

Usage

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);

Example

See example/download_documents.php for a complete runnable script.