Sending Credit Notes

This is the right section for you if you are acting as a supplier and looking to send credit notes to your customers.

Throughout this guide you will learn how to send new credit notes to the Procuros API.

PHP examples are included but you will likely also want to look at the relevant API calls in the API reference.

Table of Contents

Process

These are usually the steps taken when sending a credit note to Procuros:

  1. Check, if this document should be sent via Procuros (see: Enabled Trade Partners)
  2. Verify this document has not already been sent (see: Tracking Document Status)
  3. Build the transaction payload to be sent via Procuros
  4. Send the transaction payload via the Procuros API

Authentication

You will need an API token to authenticate.
We use a bearer token which has to be included in each request you send to the API.

Please read the Authentication section of our API reference for a detailed description.

Error Handling

The API will return a 2xx status code for successful requests. Anything else indicates an error.

Please read the Errors section of our API reference for a detailed description plus examples of how to handle them.

Send Credit Notes

The API call Send transaction is used to create transactions, including credit notes.

The following fields are required:

  • type (Transaction type. In this case CREDIT_NOTE)
  • content (The details of the credit note.)

Inside the content you will need to build all credit note items. All details can be found in the CREDIT_NOTE schema as described in the API reference.

An example request would look like:

// install dependency
// $ composer require guzzlehttp/guzzle

<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$transaction = [
    'type' => 'CREDIT_NOTE',
    'content' => [
        'header' => [
            'buyer' => [
                'identifiers' => [
                    [
                        'identifier' => '3220010000001',
                        'domain' => 'GS1',
                    ],
                ],
            ],
            'supplier' => [
                'identifiers' => [
                    [
                        'identifier' => '3220010000004',
                        'domain' => 'GS1',
                    ],
                ],
            ],
            'type' => 'CORRECTION',
            'creditNoteIdentifier' => 'valid-credit-note-identifier-1',
            'creditNoteDate' => '2022-05-09',
            'reason' => 'valid-credit-note-reason-1',
            'invoiceIdentifier' => 'valid-invoice-identifier-1',
            'invoiceDate' => '2022-05-09',
            'shippingNoticeIdentifier' => 'valid-credit-note-shipment-identifier-1',
            'shippingNoticeDate' => '2022-05-07',
            'orderIdentifier' => 'valid-credit-note-order-identifier-1',
            'orderDate' => '2022-05-01',
            'paymentTerms' => [],
        ],
        'items' => [
            [
                'lineNumber' => 1,
                'identifiers' => [
                    [
                        'identifier' => 'valid-invoice-item-identifier-1',
                        'domain' => 'GS1',
                    ],
                ],
                'isDepositItem' => false,
                'quantity' => 10,
                'unitPrice' => 4.5,
                'tax' => [
                    'amount' => 8.55,
                    'percentage' => 19,
                ],
            ],
            [
                'lineNumber' => 2,
                'identifiers' => [
                    [
                        'identifier' => 'valid-invoice-item-identifier-2',
                        'domain' => 'GS1',
                    ],
                ],
                'isDepositItem' => true,
                'quantity' => 10,
                'unitPrice' => 4.5,
                'tax' => [
                    'amount' => 0,
                    'percentage' => 0,
                ],
            ],
        ],
        'summary' => [
            'subtotalAmount' => 90,
            'grossAmount' => 98.55,
            'netAmount' => 98.55,
            'dueAmount' => 98.55,
            'totalAmountWithoutTax' => 90,
            'totalCharges' => 8.55,
            'totalAllowances' => 0,
            'tax' => [
                'total' => 1,
                'items' => [
                    [
                        'percentage' => 19,
                        'taxableAmount' => 44.5,
                        'taxAmount' => 8.5,
                        'category' => 'Mwst.',
                        'description' => 'Mehrwertsteuer',
                    ]
                ],
                'description' => 'Tax Summary',
            ],
        ],
    ],
];


$response = $client->request('POST', 'https://api.procuros.io/v2/transactions', [
  'headers' => [
    'Accept' => 'application/json',
    'Authorization' => 'Bearer <your-api-token>',
  ],
  'json' => $transaction,
]);

Mark Document Status

Finally, as per the instructions mentioned under Tracking Document Status you must now track the status of the document locally, based on the returned HTTP response.

The document should be marked with either status TRANSMITTED or NO_ACTION. If there is an error with the document and it is not accepted, do not mark it with a status so it may be retried. For more information on retrying failed documents, please see: Retrying Documents.

For example:

$statusCode = $response->getStatusCode();

if ($statusCode == 201) {
  $document->updateProcurosStatus("TRANSMITTED");
} else if ($statusCode == 202) {
  $document->updateProcurosStatus("NO_ACTION");
} else {
  // No need to do anything if it's not accepted, in an error case the document should be retried.
}