kubinyete/adiq-edi-php

Unofficial library for reading EDI files provided by Adiq.

1.0.2 2024-02-16 12:47 UTC

This package is auto-updated.

Last update: 2024-11-17 18:13:24 UTC


README

pt-BR: Uma biblioteca simples e direta para carregar arquivos EDI da adquirente Adiq Pagamentos

en-US: A straightfoward library for loading EDI files from Adiq Pagamentos

NOTA: Este guia está primariamente em inglês, caso haja necessidade, será adicionado uma versão em pt-BR no futuro.

Installation

Let's start by requiring the package by running the following command

composer require kubinyete/adiq-edi-php

Usage

You can just instantiate a new document object from a data stream, after that, you should be able to directly check each envelope that is present on file, and iterate over each entry accordingly.

// Opening the document by providing a file path
$document = Document::open(__DIR__ . DIRECTORY_SEPARATOR . 'EDI_020_20231001_11111_0011_001111111_000111.txt');
// Metadata information can be found via
$metadata = $document->getMetadata();

dump([
    'fileVersion' => $metadata->version,
    'fileDate' => $metadata->date,
    'movement' => $metadata->movement,
    'acquirerName' => $metadata->acquirer,
    'establishmentCode' => $metadata->establishmentCode,
]);

// For each envelope available
foreach ($document->getEnvelopes() as $envelope) {
    /** @var Envelope $envelope */
    dump([
        'envelopeDate' => $envelope->date,
        'envelopeCurrencyCode' => $envelope->currencyCode,
        'entriesCount' => $envelope->registryTotalCount,
        'entriesCreditSum' => $envelope->registryTotalCreditAmount,
    ]);

    // For each entry (CV, AJ, CC) inside our envelope.
    foreach ($envelope->getEntries() as $entry) {
        /** @var EDIRegistry $entry */
        dump($registry);
    }
}