Integrate to PayEx Invoice API
Introduction
This api is used to retrieve information related to the customer's invoices.
PayEx supports HTTP headers for tracking that are used for troubleshooting purposes, implement according to specification
Each resource in the API corresponds to its own route. All routes are structured according to a specific standard, explained below
The below route is an example of a route towards resource3Id, to operate on this resource you must also include the ids of its parentresources in the route.
lf-api.payex.com/ledger/{Subdomain}/v1/{LedgerNumber}/resource1/{resource1Id}/resource2/{resource2Id}/resource3/{resource3Id}
Route segment | Description |
---|---|
Subdomain | In this part of the API it will be invoice |
LedgerNumber | The ledger identifier/number at PayEx |
resource1Id | Identifier of resource1 |
resource2Id | identifier of resource2, subresource to resource1 |
resource3Id | identifier of resource3, subresource to resource2 |
Routes that occurs in examples of this documentation will use the following identifiers
Resource | Identifier |
---|---|
LedgerNumber | XXX |
Invoices | NNN (invoiceNo) |
Documents | YYY (type) |
Invoice
The invoice resource is located under ledger/invoice/v1/ api. This resource is used to get general information about existing invoices and its current state. Creation of new invoices is done through other resource.
Get specific invoice
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"@id" : "/ledger/invoice/v1/XXX/invoices/12345",
"created" : "2019-05-06T00:00:00",
"invoiceNo" : "12345",
"externalInvoiceId" : "987654321",
"status" : "pending|open|closed",
"claimLevel" : "Invoice|RestReminder|Reminder|SecondReminder|CollectionClaim|DebtCollection",
"currentDebt" : 463.42,
"originalAmount" : 354.10,
"currency" : "sek",
"invoiceDate" : "2018-10-01T00:00:00",
"dueDate" : "2018-10-01T00:00:00",
"seller" : {
"name" : "testshop",
"number" : "12345"
},
"debt" : {
"capital" : 354.10,
"remiderFee" : 20.00,
"collectionFee" : 80.00,
"penaltyInterest" : 8.00,
"calculatedPenaltyInterest" : 1.32
},
"penaltyInterestRate": 15.00,
"bankPayment": {
"bankAccountNo": "123",
"bankAccountType": "BGSE",
"bic": "123456",
"iban": "SE12345678945631",
"paymentReference": "54867165675646"
},
"customer" : "/ledger/customer/v1/customers/XYZABC",
"transactions" : "/ledger/invoice/v1/XXX/invoices/12345/transactions",
"activePaymentOrders": "/ledger/invoice/v1/XXX/invoices/NNN/active-payment-orders",
"journal" : "/ledger/invoice/v1/XXX/invoices/12345/journal",
"documents": "/ledger/invoice/v1/XXX/invoices/NNN/documents",
"operations": [
{
"rel": "generate-invoice-portal-link",
"method": "POST",
"href": "/ledger/invoice/v1/XXX/invoices/NNN/generate-invoice-portal-link"
},
{
"rel": "transfer-to-account",
"method": "POST",
"href": "/ledger/invoice/v1/XXX/invoices/NNN/transfer-to-account"
}
],
}
Get specific customers invoices
Use the querystring parameter "customerNo" to list invoices for a specific customer.
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"items": [
{
"@id" : "/ledger/invoice/v1/XXX/invoices/12345",
"invoiceNo" : "12345",
"status" : "pending",
"claimLevel" : "Invoice",
"originalAmount" : 354.10,
"dueDate" : "2021-10-01T00:00:00",
"customerNo" : "XYZABC"
},
{
"@id" : "/ledger/invoice/v1/XXX/invoices/987654",
"invoiceNo" : "987654",
"status" : "open",
"claimLevel" : "Invoice",
"originalAmount" : 122.00,
"dueDate" : "2020-10-01T00:00:00",
"customerNo" : "XYZABC"
},
{
"@id" : "/ledger/invoice/v1/XXX/invoices/456321",
"invoiceNo" : "456321",
"status" : "closed",
"claimLevel" : "Invoice",
"originalAmount" : 846.50,
"dueDate" : "2020-08-01T00:00:00",
"customerNo" : "XYZABC"
}
]
}
Content-Type: application/json
{
"items": [
{
"@id" : "/ledger/invoice/v1/XXX/invoices/12345",
"invoiceNo" : "12345",
"status" : "pending",
"claimLevel" : "Invoice",
"originalAmount" : 354.10,
"currency" : "sek",
"invoiceDate" : "2021-09-15T00:00:00",
"dueDate" : "2021-10-01T00:00:00",
"customerNo" : "XYZABC"
},
{
"@id" : "/ledger/invoice/v1/XXX/invoices/987654",
"invoiceNo" : "987654",
"status" : "open",
"claimLevel" : "Invoice",
"originalAmount" : 122.00,
"currency" : "sek",
"invoiceDate" : "2021-09-15T00:00:00",
"dueDate" : "2020-10-01T00:00:00",
"customerNo" : "XYZABC"
},
{
"@id" : "/ledger/invoice/v1/XXX/invoices/456321",
"invoiceNo" : "456321",
"status" : "closed",
"claimLevel" : "Invoice",
"originalAmount" : 846.50,
"currency" : "sek",
"invoiceDate" : "2021-09-15T00:00:00",
"dueDate" : "2020-08-01T00:00:00",
"customerNo" : "XYZABC"
}
]
}
Invoice resource properties
Property | Data type | Format | Description |
---|---|---|---|
@id | string | Maxlength: | Uri of the specific account |
created | date | Date when the invoice was created in the system | |
invoiceNo | string | Maxlength: 50 | The identifier of the account |
externalInvoiceId | string | Maxlength: 50 | External identifier of the invoice |
status | string | Maxlength: 25 | Status of the invoice
|
claimLevel | string | Maxlength: 25 | Current claim level of the invoice.
|
currentDebt | decimal | Total current debt of all balances (including capital / interest / fees, etc.). This value can be either positive or negative. (positive value means it is a debt) | |
originalAmount | decimal | The original debt amount stated on the invoice. | |
currency | string | ISO 4217 | Currency of the invoice |
invoiceDate | date | ISO 8601 | Date when the invoice was created (printed on the invoice document) |
dueDate | date | ISO 8601 | Duedate of the invoice. This value does not exist for credit invoices |
seller.name | string | Name of the seller related to the invoice | |
seller.number | string | The identifier of the seller | |
debt | object | Current debt of the invoices separated in the different debt types | |
debt.capital | decimal | This value only exists if there is any capital amount | |
debt.reminderFee | decimal | This value only exists if there is any reminder fee (also includes businessRemiderFee) | |
debt.collectionFee | decimal | This value only exists if there is any collection fee | |
debt.penaltyInterest | decimal | This value only exists if there is any penalty interest | |
debt.calculatedPenaltyInterest | decimal | Todays pending calculated penalty interest. Will be valid if a payment is made today. This value only exists if there is any calculated penalty interest. | |
penaltyInterestRate | decimal | Percentage | yearly penalty interestrate (optional) |
bankPayment | object | optional. This object is only visible if the invoice is ready to be paid. Does not exists for invoices with status "closed", or for creditinvoices | |
bankPayment.bankAccountNo | string | Maxlength: 15 | bankaccount for payment |
bankPayment.bankAccountType | string | Maxlength: 10 | BankAccountTypes:
|
bankPayment.bic | string | Maxlength: 11 | Bank Identifier Code (BIC) |
bankPayment.iban | string | Maxlength: 34 | International Bank Account Number (IBAN) |
bankPayment.paymentReference | string | Maxlength: 50 | reference to specify on the payment |
customer | string | Uri | Uri to the customer resource related to the invoice |
transactions | string | Uri | List all transactions that has occured on the invoice |
activePaymentOrders | string | Uri | View scheduled payment orders |
journal | string | Uri | Lists events that has occured on the invoice |
documents | string | Uri | View the actual invoice document (and other related documents), how it has been distributed etc. |
Documents
The documents resources contains basic info of each invoice, reminder, letters etc. that has been produced related to the invoice. It also includes a url to download the actual document.
List all documents of an invoice
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"@id": "/ledger/invoice/v1/501/invoices/NNN/documents",
"items" : [
{
"@id": "/ledger/invoice/v1/XXX/invoices/NNN/documents/852147",
"date": "2018-11-15T00:00:00",
"type" : "invoice",
"distributionMethod" : "NotDistributed|Postal|Kivra|EInvoice|EMail",
"document": "/ledger/invoice/v1/XXX/invoices/NNN/documents/852147/document"
},
{
"@id": "/ledger/invoice/v1/XXX/invoices/NNN/documents/123654",
"date": "2018-11-15T00:00:00",
"type" : "reminder",
"distributionMethod" : "NotDistributed|Postal|Kivra|EInvoice|EMail",
"document": "/ledger/invoice/v1/XXX/invoices/NNN/documents/123654/document"
}
]
}
Get specific document
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"@id": "/ledger/invoice/v1/XXX/invoices/NNN/documents/123645",
"date": "2018-11-15T00:00:00",
"type" : "reminder",
"distributionMethod" : "NotDistributed|Postal|Kivra|EInvoice|EMail",
"document": "/ledger/invoice/v1/XXX/invoices/NNN/documents/123645/document"
}
Document resource properties
Property | Data type | Format | Description |
---|---|---|---|
@id | string | Uri | |
date | date | ISO 8601 | Date when the document was created |
type | string | Currently available types of document
| |
distributionMethod | string |
| |
document | string | Uri | Uri to download the actual document, usually pdf (content type in response). |
Transactions
This resource lists all transactions that has occured on the invoice. The resource does not support "GET" on individual transactions, only listing of all transactions.
Property "typeName" is ment to be displayed directly "as is" in a customer portal, it is translated to a readable text in the language configured on the current company.
List all transactions that has occured on an invoice
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"@id": "/ledger/invoice/v1/501/invoices/NNN/transactions",
"items" : [
{
"type": "disbursement",
"typeName": "Utbetalningsuppdrag skapat",
"reference": "",
"amount": 50.00,
"date": "2019-11-09T00:00:00"
},
{
"type": "payment",
"typeName": "Betalning",
"reference": "",
"amount": -100.00,
"date": "2019-11-09T00:00:00"
},
{
"type": "credit",
"typeName": "Kreditering",
"reference": "",
"amount": -100.00,
"date": "2019-11-02T00:00:00",
"cause" : {
"type": "bankruptcy",
"typeName": "Konkurs"
}
},
{
"type": "credit",
"typeName": "Kreditering",
"reference": "korrigering dröjsmålsränta",
"amount": -00.85,
"date": "2019-11-02T00:00:00",
"cause" : {
"type": "remission",
"typeName": "Efterskänkes"
}
},
{
"type": "credit",
"typeName": "Kreditering",
"reference": "reglering mot kreditfaktura NNN",
"amount": -100.00,
"date": "2019-11-02T00:00:00",
},
{
"type": "collectionFee",
"typeName": "Inkassoavgift",
"reference": "",
"amount": 180.00,
"date": "2019-11-02T00:00:00",
},
{
"type": "reminderFee",
"typeName": "Påminnelseavgift",
"reference": "",
"amount": 30.00,
"date": "2019-11-02T00:00:00",
},
{
"type": "interest",
"typeName": "ränta",
"reference": "",
"amount": 2.00,
"date": "2019-11-02T00:00:00",
},
{
"type": "invoice",
"typeName": "Faktura",
"reference": "butiksnamn, Orderref. 345",
"amount": 200.00,
"date": "2020-10-09T00:00:00"
}
]
}
Transaction resource properties
Property | Data type | Description |
---|---|---|
@id | string | |
type | string | Type of transaction |
typeName | string | The type of transaction in form of a readable translated text (the local language of the current company) The following types can occur on a invoice
|
reference | string | Transaction reference |
amount | decimal | Amount ot the transaction |
date | date | Date when the transaction occured |
cause | object | This object is available when there is a specific cause to why the transaction has occured |
cause.type | string | Type of cause to why the transaction has occured |
cause.typeName | string | The type of cause in form of a readable translated text (in the local language of the current company) |
Active payment orders
This resource corresponds to an active / scheduled payment order placed against the specific account, the end-customer will be debited at the given executeDate.
Get active payment orders for an account
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"operations": null,
"items": [
{
"paymentMethod": "autogiro",
"executeDate": "2020-02-15",
"amount": 200.00
}
]
}
Active-payment-orders resource properties
Property | Data type | Description |
---|---|---|
paymentMethod | string | paymentMethods:
|
executeDate | Date | The date when the customers bankaccount will be charged |
amount | decimal | The amount that will be withdrawn from the bankaccount |
Journal
This resource lists all events that has occured on the invoice, in a sorted timeline.
Get journal entries for the invoice
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"operations": null,
"items": [
{
"type": "ComplaintReceived",
"date" : "2020-09-01T00:00:00",
"description" : ""
},
{
"type": "SecondReminderSent",
"date" : "2020-09-01T00:00:00",
"description" : ""
},
{
"type": "ReminderSent",
"date" : "2020-09-01T00:00:00",
"description" : ""
}
],
"view": {
"@id": "/ledger/invoice/v1/XXX/invoices/NNN/journal?$top=2&$skip=0",
"next": "/ledger/invoice/v1/XXX/invoices/NNN/journal?$top=2&$skip=2"
}
}
Journal resource properties
Property | Data type | Description |
---|---|---|
type | string | type:
|
date | Date | The date when the journal entry occured |
description | string | detailed description of the entry (if available) |
Register direct payment
operation for registration of direct payments against invoices
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"amount" : 100.00,
"paymentDate" : "2021-04-27",
"transactionCause" : "psp"
}
Register-direct-payment request properties
Property | Data type | Required | Description |
---|---|---|---|
amount | decimal | Yes | The amount of the direct payment |
paymentDate | Date | Yes | The date when the payment was made |
transactionCause | string | No |
|
Content-Type: application/json
Settle-credit-invoice
operation to settle an existing credit invoice towards debit invoice. This operation is only be available/valid on credit-invoices
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"debitInvoiceNo": "12345",
"creditAmount": 250.00,
"sendCopy": false
}
Settle-credit-invoice request properties
Property | Data type | Required | Description |
---|---|---|---|
debitInvoiceNo | string | Yes | invoice number of the debit invoice that the credit invoice is to be settled against |
creditAmount | decimal | Yes | Amount of the credit invoice to use |
sendCopy | bool | No | Whether a new copy should be distributed to the end-customer with updated balances (after settlement has been executed) Default false |
Content-Type: application/json
Remission
operation to allow partialy remission of the debt. Usually used if there is a small debt left on the invoice after a payment hade been done, and the remaining amount should be offered.
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"balanceType": "CollectionFee",
"amount": 12.00,
"invoiceCurrentDebt": 12.00
}
remission request properties
Property | Data type | Required | Description |
---|---|---|---|
balanceType | string | Yes | The balanceType to be affected
|
amount | decimal | Yes | The amount of the specified balace type to exeute remission on |
invoiceCurrentDebt | decimal | Yes | The amount must match the current debt (excl. Calculated interest) on the invoice. currentDebt - debt.calculatedPenaltyInterest |
Content-Type: application/json
Write-down
operation to allow partialy or full write-down of the debt. the reason/cause of the write-down should be specified (affects accounting)
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"balanceType": "CollectionFee",
"amount": 12.00,
"cause": "deceased",
"invoiceCurrentDebt": 462.10
}
Write-down request properties
Property | Data type | Required | Description |
---|---|---|---|
balanceType | string | Yes | The balanceType to be affected
|
amount | decimal | Yes | The amount of the specified balace type to write-down |
cause | string | Yes | The cause of the write-down
If field is null, Then defaults to "Unknown". Case-Sensitive |
invoiceCurrentDebt | decimal | Yes | The amount must match the current debt (excl. Calculated interest) on the invoice. currentDebt - debt.calculatedPenaltyInterest |
Content-Type: application/json
Respite
Resource to create or view respite
Get respite
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"validToDate": "2021-08-01",
"reason": "..."
}
Create respite
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"validToDate": "2021-08-01",
"reason": "..."
}
Content-Type: application/json
Respite request properties
Property | Data type | Required | Description |
---|---|---|---|
validToDate | Date | Yes | Respite is valid to this date |
reason | string | Yes | Reason for why the respite was created. |
Active-disbursement-orders
View or create disbursement orders, only available for credit-invoices
Get active-disbursement-orders
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
Content-Type: application/json
{
"items" :
[
{
"@id" : "../ledger/v1/501/invoices/12345/active-disbursement-orders/456789",
"amount" : 10,
"norwegianBankAccount" : {
"accountNo" : "1234"
}
},
{
"@id" : "../ledger/v1/501/invoices/12345/active-disbursement-orders/456788",
"amount" : 10,
"international" : {
"iban" : "123456",
"bic" : "SWED..."
}
},
{
"@id" : "../ledger/v1/501/invoices/12345/active-disbursement-orders/456787",
"amount" : 10,
"swedishBankAccount" : {
"accountNo" : "123",
"accountType" : "BKSE | PGSE | BGSE"
}
},
{
"@id" : "../ledger/v1/501/invoices/12345/active-disbursement-orders/456786",
"amount" : 10,
"swedishSus" : {
"nationalIdentifier": {
"regNo" : "YYYYMMDD-NNNN",
"countryCode" : "SE"
},
"address" : {
"addressee" : "Kalle Axelstopp",
"streetAddress" : "Axelgatan 18",
"coAddress" : null,
"city" : "STOCKHOLM",
"zipCode" : "16872",
"countryCode" : "se"
}
}
}
]
}
Create disbursement order towards a norwegian bank account
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"amount" : 10,
"norwegianBankAccount" : {
"accountNo" : "1234"
}
}
Create disbursement order towards a international bank account (IBAN)
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"amount" : 10,
"international" : {
"iban" : "123456",
"bic" : "SWED..."
}
}
Create disbursement order towards a swedish bank account
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"amount" : 100,
"swedishBankAccount" : {
"accountNo" : "123",
"accountType" : "BKSE | PGSE | BGSE"
}
}
Create disbursement order using "Swedbanks lön- och utbetalningssystem (SUS)"
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"amount" : 100,
"swedishSus" : {
"nationalIdentifier": {
"regNo" : "YYYYMMDD-NNNN",
"countryCode" : "SE"
},
"address" : {
"addressee" : "Kalle Axelstopp",
"streetAddress" : "Axelgatan 18",
"coAddress" : null,
"city" : "STOCKHOLM",
"zipCode" : "16872",
"countryCode" : "se",
}
}
}
Content-Type: application/json
Respite request properties
Property | Data type | Required | Description |
---|---|---|---|
amount | decimal | Yes | |
norwegianBankAccount | object | No* | |
accountNo | string | Yes | |
swedishBankAccount | object | No* | |
clearingNo | string | Yes | |
accountNo | string | Yes | |
international | object | No* | |
iban | string | Yes | |
bic | string | Yes | |
swedishSus | object | No* | |
nationalIdentifier | object | Yes | |
regNo | string | Yes | |
countryCode | string | Yes | |
address | object | Yes | |
addressee | string | Yes | |
streetAddress | string | No | |
coAddress | string | No | |
city | string | Yes | |
zipCode | string | Yes | |
countryCode | string | Yes | |
* One and only one of the specified objects can be set at each request
Transfer-to-account
operation transfer current capital debt on the invoice to a provided account. This will close the invoice.
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"accountNo" : "123",
}
Transfer-to-account request properties
Property | Data type | Required | Description |
---|---|---|---|
accountNo | string | Yes | account number to the to transfer current capital debt into |
Content-Type: application/json
Generate-invoice-portal-link
Creates a new public available (no authorization needed) link to the targeted invoice. Default lifetime of a link is 120 days. Creating new links does not affect old links.
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
}
Content-Type: application/json
{
"invoicePortalLink": "https://public-invoice-example.com/sv/XXX?token=eyJhbGciOiJSUzI1Ni..."
}
Problems
All errors from the api are returned in the form of "problems" (response body), except for the http status code itself.
The problem object contain more detailed info on what the error is. The "type" property can be used to programmatically interpret the error as it contains a code definition of the problem.
Other properties can be useful for logging and subsequent troubleshooting. Some problems are extended with additional parameters so it may be a good idea to log response body as raw data to include these.
Problems of type validation does contain an additional list ("Problems") that describes exactly which parameter that failed the validation
Example
Content-Type: application/problem+json
{
"Type" : "ledger/{domain}/v1/problems/validation",
"Title" : "A validation error occurred",
"Status" : 400,
"Instance" : "215d4206-ca35-4f43-85ad-169c8f6d4ec1",
"Detail" : "A validation error occurred. Please fix the problems mentioned in the 'problems' property below.",
"Problems" :
{
"amount" : [
"Expected value between [0,01]-[79228162514264337593543950335] actual [0]"
]
}
}
Problem types
Problem type (code) | Httpstatus | Description |
---|---|---|
forbidden | 403 | occurs if access to method is not allowed. |
customer-not-found | 404 | can occur if customernumber is part of the querystring towards invoice resource |
invoice-not-found | 404 | |
missing-offer | 409 | Invoice is not a candidate for transfer-to-account. This has nothing to do with the provided Account |
missing-account-for-billing-account | 409 | No account found on the provided AccountNo, can be expected on the us of transfer-to-account operation |
not-acceptable-for-conversion | 409 | Invoice or account was not acceptable for transfer. This could be caused a number of parameters both on the invoice and the account. |
credit-check-rejected | 422 | Score does not approve the conversion |
customer-mismatch | 422 | Invoice and account is on separate customers in the transfer-to-account request |