Introduction
The Payer REST API enables you to create magic payment experiences - based on your customers needs. It puts you in the driver's seat with full control of the flow.
Each service has its own set of functions that delivers value individually and can be applied - before, during and after the order moment. This enables you to use the functions to deliver value just in the right micro-moment throughout your customer’s journey.
Even though the services can create value when used individually, combined, you can create magic.
Take command and use single functions or combos in your scenario in the right micro-moment and generate maximum value.
In need of some inspiration or don’t know where to start? Don’t hesitate to contact us for guidance, tips & tricks or examples of experiences to start from
Integration guidelines
Formats
- All amounts are in cents, e.g. if you're using USD the amounts will be in cent
- ISO-8601 Standard for date and time stamps.
- UTF-8 text encoding.
VAT
When specifying prices of items in Orders, the unitPrice and subtotalPrice fields are specified including VAT.
Non-breaking updates of the API
When using Payers API, your service should allow for dynamic changes. Such as:
- New valid values for enums may be added.
- New fields may be added to a response.
Retrying requests
When sending a non-GET HTTP request to the API, you can add a Payer-Request-ID
header
with a unique UUID to the request. This header allows you to retry the request (using the
same Payer-Request-ID
) if you're unsure whether or not Payer successfully handled the
request. For example, if there was a network problem so that you couldn't receive the
response to the request.
If the request has already been handled, a 409 Conflict
will be returned.
GET requests are excluded from this mechanism, since it's always safe to do GET requests
multiple times.
Authentication
Payer B2B uses authentication with a OAuth2 Bearer token for all endpoints except the
authentication endpoint. For <credentials>
, we use the Base64-encoded string of
clientId:clientSecret
. On macOS/Linux you can generate it with:
echo -n clientId:clientSecret | base64
On Windows, you can use certutil -encode
.
Use the following command with your <credentials>
to authenticate:
curl -X POST \
https://b2b.payer.se/oauth2/token \
-H 'Accept: application/json' \
-H 'Authorization: Basic <credentials>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d grant_type=client_credentials
The POST
will return a JSON response containing an OAuth2 Bearer token:
{
"access_token": "some-very-long-token",
"expires_in": 3599,
"scope": "",
"token_type": "bearer"
}
For all other endpoints in Payer B2B, use the access_token
from the response as OAuth2
Bearer token with the HTTP header Authorization: Bearer <some-very-long-token>
.
The token expires in one hour. You will notice this in the form of a 401 Unauthorized reply to a request. You should act on this reply by performing a re-authentication and then retrying the request. You are also free to keep track of the token age yourself and renew before it expires.
Common authentication errors
If you are not able to access the API, some possible errors are:
- The access token was not provided in the
Authorization
header. - The
Authorization
header was not prefixed withBearer
. - The access token has expired. Generate a new token and perform the request again.
- You are not allowed to access the API. Contact Payer if you need access to additional APIs.
If you have other issues with authentication, contact Payer for assistance.
Generated server url
Invoices V2
API
Sends a copy of an invoice.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Pays out the outstanding amount from a credit invoice back to the party that made the original payment.
It is only possible to use credit invoices created with API V2.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Pays an invoice with an outstanding amount from a credit invoice.
It is only possible to use invoices and credit invoices created with API V2.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Creates a credit invoice with items that credits items from the original invoice, items to be credited are identified by item position.
An Invoice created with the V2 API can only be credited using the V2 API A credit invoice can be linked to the original invoice or it can be standalone. When using the standalone credit invoice as payment for another invoice, the original invoice will not be affected - no debt will be added to the original invoice. Either invoiceNumber or referenceId must be provided
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns a credit invoice for given line items.
An Invoice created with the V2 API can only be credited using the V2 API A credit invoice can be linked to the original invoice or it can be standalone. When using the standalone credit invoice as payment for another invoice, the original invoice will not be affected - no debt will be added to the original invoice. Either invoiceNumber or referenceId must be provided
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns a credit invoice for the full amount of the provided invoice.
An Invoice created with the V2 API can only be credited using the V2 API A credit invoice can be linked to the original invoice or it can be standalone. When using the standalone credit invoice as payment for another invoice, the original invoice will not be affected - no debt will be added to the original invoice. Either invoiceNumber or referenceId must be provided
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns an invoice for a given invoice number
Note: By default, the invoice is returned in Inc-Vat format, even if the invoice was originally created with a different calculation mode. Please use the originalCalculationModeResponse flag if you don't want that. Also note: An Invoice created with the V2 API can only be fetched using the V2 API.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns invoices where the invoice customer have the given reg number or vat id
Batch size is 20. If more invoices exists, the next invoice number is returned to be used in future requests. Note: By default, the invoice is returned in Inc-Vat format, even if the invoice was originally created with a different calculation mode. Please use the originalCalculationModeResponse flag if you don't want that. Also note: An Invoice created with the V2 API can only be fetched using the V2 API.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns all credit invoices for a given orderId or orderReferenceId
An Invoice created with the V2 API can only be fetched using the V2 API
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Returns invoices with invoice number >= than given invoice number
Batch size is 20. If more invoices exists, the next invoice number is returned to be used in future requests. Note: By default, the invoice is returned in Inc-Vat format, even if the invoice was originally created with a different calculation mode. Please use the originalCalculationModeResponse flag if you don't want that. Also note: An Invoice created with the V2 API can only be fetched using the V2 API.
OK
Bad Request
Unauthorized
Forbidden
Not Found
Internal Server Error
Service Unavailable
Invoices V3
API
Card Payments
API
Orders V2
API
Invoice Reminders
API
Customers V1
API
Direct Bank Payments
API
Payment Requests
API
Payments V2
API
Bank Payments V1
API