../credit-account

Integrate to PayEx Credit Account API 

ChangeLog

Glossary

  •  

Introduction

Accounts

Request
GET /ledger/credit-account/v1/XXX/accounts HTTP/1.1
Host: -
Authorization: Bearer <Token>
Content-Type: application/json

If the authorization post succeeds, or if a get method is performed to retrieve an existing authorization, it should respond with something like the following:

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
   "sellerNumber" : "654",        
    "invoice" : {
       "amountInclVat" : 100,
       "currency" : "SEK",
       "invoiceNumber" : "852",
       "dueDate" : "2019-06-27",
       "collectionReferenceText" : "Shoes",
       "invoiceDate" : "2019-06-07",
       "distributionDate" : "2019-06-08"
     },           
    "buyer" : {
       "emailAddress" : "test@testshop.se",
       "cellPhone" : "+46701234456",  
       "nationalConsumerIdentifier" : {
           "value" : "19101010-1010",
           "countryCode" : "SE"                
        },
       "nationalOrganizationIdentifier" : {
           "value" : null,
           "countryCode" : null               
        },   
       "invoiceAddress" : {
           "name" : "John Smith",
           "streetAddress" : "Teststreet",
           "city" : "Testcity",
           "coAddress" : "",
           "zipCode" : "12345",
           "countryCode" : "SE"
        }
    },
   "invoicePurchaseDetails" : {
       "paymentReference" : "426523791",
       "paymentAccount" : {
           "accountType" : "BGSE",
           "accountNumber" : "1234-45",
           "bic" : "SWEDSESS",
           "iban" : "SE4550000000058398257466"
        },
       "invoiceDenuntiationText" : "Vår fordran enligt denna faktura har pantsatts till Acquirer AB ............"
     },
   "authorizationId" : 123,
   "@id" : "/ledger/invoice-purchase/v1/501/authorizations/123",
   "parentHREF": "/",
   "operations" : [
        {
           "rel" : "create-capture",
           "method" : "post",
           "href" : "/ledger/invoice-purchase/v1/501/authorizations/123/captures"
        },
        {
           "rel" : "create-credit",
           "method" : "post",
           "href" : "/ledger/invoice-purchase/v1/501/authorizations/123/credits"
        },
        {
           "rel" : "create-cancellation",
           "method" : "post",
           "href" : "/ledger/invoice-purchase/v1/501/authorizations/123/cancellations"
        }
    ],
   "captures": "/ledger/invoice-purchase/v1/501/authorizations/123/captures",
   "credits" : "/ledger/invoice-purchase/v1/501/authorizations/123/credits",
   "cancellations" : "/ledger/invoice-purchase/v1/501/authorizations/123/cancellations"    
}

Resource properties

PropertyData typeFormatRequired in postDescription
sellerNumberstringMaxlength: 15YThe identifier of the specific seller in the acquirer system
invoice.amountInclVatdecimalN.NNYThe amount including VAT, always two decimals
invoice.currencystringISO 4217YThe currency of the invoice ("SEK" etc.)
invoice.invoiceNumberstringMaxlength: 50
[A-Za-z0-9\-]+
YA unique reference from the seller system. It must be unique within each seller.
invoice.dueDatestringISO 8601YExample: "2019-06-04"
invoice.collectionReferenceTextstringMaxlength: 50Y 
invoice.invoiceDatestringISO 8601YExample: "2019-06-04"
invoice.distributionDatestringISO 8601YExample: "2019-06-04"
buyer.emailAddressstringMaxlength: 60
[^@]+@[^\.]+\..+
  
buyer.cellPhonestringMaxlength: 20 Example: "+46701234567"
buyer.nationalConsumerIdentifier.valuestringYYYYMMDD-NNNCY*A valid swedish "personnummer"
buyer.nationalConsumerIdentifier.countryCodestringISO 3166-1 alpha-2Y*The countrycode of the identifiers nationality, ("SE")
buyer.nationalOrganizationIdentifier.valuestringNNNNNN-NNNCY*A valid swedish "organisationsnummer"
buyer.nationalOrganizationIdentifier.countryCodestringISO 3166-1 alpha-2Y*The countrycode of the identifiers nationality, ("SE")
buyer.invoiceAddress.namestringMaxlength: 72Y 
buyer.invoiceAddress.streetAddressstringMaxlength: 35Y 
buyer.invoiceAddress.citystringMaxlength: 30Y 
buyer.invoiceAddress.coAddressstringMaxlength: 35Y 
buyer.invoiceAddress.zipCodestringMaxlength: 9Y 
buyer.invoiceAddress.countryCodestringISO 3166-1 alpha-2YExample: "SE"
invoicePurchaseDetails.paymentReferencestringMaxlength: 50No, output onlyGenerated paymentreference
invoicePurchaseDetails.paymentAccount.accountTypestringMaxlength: 4No, output onlyType of account, eg. BankGiro: "BGSE"
invoicePurchaseDetails.paymentAccount.accountNumberstringMaxlength: 15No, output only 
invoicePurchaseDetails.paymentAccount.bicstringMaxlength: 11No, output only 
invoicePurchaseDetails.paymentAccount.ibanstringMaxlength: 34No, output only 
invoicePurchaseDetails.invoiceDenuntiationTextstringMaxlength: 800No, output onlyLegal text to print on invoice to buyer, informs about the invoice transferred to the acquirer.
authorizationIdnumber
(long)
64-bit integerNo, output onlyidentifier of the created authorization

* Either buyer.nationalConsumerIdentifier or buyer.nationalOrganizationIdentifier must be specified in the request

Captures

If the seller decides to proceed with the process and let the acquirer purchase the invoice, a call to captures must be made. A post request is sent to the specific capture URL (that was provided in the authorization resource response), the request must contain the actual PDF of the invoice that is to be distributed to the buyer.

InvoicePurchase external - Capture.svg

To capture the authorization (with authorizationId 123 in the example below) and complete the invoice purchase, we need to perform a post request as below

Request
POST /ledger/invoice-purchase/v1/XXX/authorization/123/captures HTTP/1.1
Host: -
Authorization: Bearer <Token>
Content-Type: application/json

{       
   "invoicePdfData" : ""
}

Request properties

PropertyData typeRequired in postFormatDescription
invoicePdfDatastringYBase64 encoded byte arraydata of the valid pdf document/invoice

If the capture succeeds, it should respond with http status 204

Response
HTTP/1.1 201 Created
Content-Type: application/json

{  
}

Cancellations

The reservation must be cancelled if the seller aborts the process (for any reason) after a successful call to authorizations has been made.
This is done by sending a request to the cancellation URL that was provided in the response of the actual authorization call.

An already captured authorization cannot be cancelled.

InvoicePurchase external - Cancel.svg

To cancel an authorization (with authorizationId 123 in the example below), we need to perform a post request as below

Request
POST /ledger/invoice-purchase/v1/XXX/authorizations/123/cancellations HTTP/1.1
Host: -
Authorization: Bearer <Token>
Content-Type: application/json

If the cancellation succeeds, it should respond with http status 200

Response
HTTP/1.1 201 Created
Content-Type: application/json

Credits

To credit an existing invoice you first need retreive the specific authorization resource (get request). If the authorization has been captured and is valid for crediting the response will contain an URL to the credits resource. To complete the credit you need to call this URL with a post request containing the credit details.

InvoicePurchase external - Credit.svg

To credit a captured authorization (with authorizationId 123 in the example below) we need to perform a post request as below

Request
POST /ledger/invoice-purchase/v1/XXX/authorization/123/credits HTTP/1.1
Host: -
Authorization: Bearer <Token>
Content-Type: application/json

{
   "amountInclVat" : 100
}

If the credit succeeds, it should respond with something like the following:

Response
HTTP/1.1 201 Created
Content-Type: application/json

{
   "amountInclVat" : 100,
   "creditedAmount" : 100,
   "@id" : "/ledger/invoice-purchase/v1/501/authorizations/credits/456",
   "parentHREF": "/ledger/invoice-purchase/v1/501/authorizations/123"
}

Resource properties

PropertyData typeFormatRequired in postDescription
amountInclVatdecimalN.NNYAmount (including VAT) to credit, always two decimals
creditedAmountdecimalN.NN The actual amount that was credited, always two decimals

Problems

If an error occur or any validation failed, a "problem" response will be returned.
Below is a list of problems that can occur:

HttpStatus 401 Unauthorized

  • Token expired
  • Token invalid
  • SellerNumber does not match token
  • CompanyNumber does not match token

HttpStatus 400 Error

  • Validation: Argument required
  • Validation: Invalid value

HttpStatus 422 Unprocessable entity

  • Authorization declined

HttpStatus 409 Conflict

  • Invoice already authorized
  • Duplicate InvoiceNumber
  • Authorization is cancelled
  • Authorization already captured
  • Authorization has expired
  • Insufficient debited amount XXX

HttpStatus 501 NotImplemented

  • CompanyNumber XXX not configured
  • SellerNumber XXX not configured at PayEx
  • CompanyNumber XXX missing configuration

HttpStatus 404 NotFound

  • Authorization not found

Below is an example of a problem that will be returned if buyer.nationalConsumerIdentifier.value is not valid in the authorization post request.

Response
HTTP/1.1 400 Error
Content-Type: application/problem+json

{
   "Type": "http://[DNS]/ledger/invoice-purchase/problems/validation",
   "Title": "A validation error occurred",
   "Status": 400,
   "Instance": null,
   "Detail": "A validation error occurred. Please fix the problems mentioned in the 'problems' property below.",
   "Problems": [
        {
           "buyer.nationalConsumerIdentifier.value": "Not a valid SE nationalConsumerIdentifier"
        }
    ]
}
Created by David Persson on 2019/12/04 09:40
   

Tips

Did you know that you can improve XWiki? Take 5 minutes to fill this survey and help this open source project!

Need help?

If you need help with XWiki you can contact: