@getpeppr/sdk 6.4.0 brings Invoice Responses
to the SDK. It is a minor release: nothing you already call changes.
import { Peppol } from "@getpeppr/sdk";
const peppol = new Peppol({ apiKey: "sk_live_..." });
// The id from the inbound.invoice.received webhook (data.receivedDocumentId)
const receivedDocumentId = "3f7c1a52-9d4e-4c1b-8a2f-6b5e0d1c7a93";
const response = await peppol.receivedDocuments.respond(
receivedDocumentId,
{
responseCode: "RE",
reasons: [{ code: "REF", text: "Purchase order number missing" }],
actions: [{ code: "NIN" }],
},
// Same key on a retry: the response is never sent twice
{ idempotencyKey: `reject-${receivedDocumentId}` },
);
console.log(response.delivery); // "submitted"
What 6.4.0 adds
peppol.receivedDocuments.respond(id, input, options?)sends the response:ABacknowledged,IPin process,UQunder query,CAconditionally accepted,RErejected,APaccepted,PDpaid.UQ,CAandREneed at least one reason.peppol.receivedDocuments.listResponses(id)returns the responses sent on a document, each with itsdeliverystate:pending,submitted,delivered,failed(with afailureReason) orunconfirmed.- The types (
InvoiceResponse,InvoiceResponseInput,InvoiceResponseCode…) and the code listsINVOICE_RESPONSE_CODES,INVOICE_RESPONSE_REASON_CODESandINVOICE_RESPONSE_ACTION_CODES.
A supplier that does not accept Invoice Responses on the Peppol network is
refused at once, and nothing is sent: PeppolApiError 422, result code
received_documents.response_not_accepted_by_sender.
The Invoice Responses guide covers the codes, the delivery states and the refusals.
Install with npm install @getpeppr/sdk@6.4.0.