The Ecster Pay API is based on straight forward RESTful architecture principles using the lightweight data-interchange format JSON. Ecster Pay works great on all devices and screens. The UI is designed to be perceived as a natural part of your webshop.
Need help getting started? Check out our Tutorials
In order to completely integrate Ecster Pay, there’s a REST API that exposes two methods – Create and Update cart. You will always need to execute Create cart, but it’s likely that you also need to execute Update cart. For both requests, you need to authorize your application.
Every call to the REST API must be made from your application’s backend.
Both calls return the same thing – a cart key. You will get a new cart key for every time you execute one of these functions and you always use the latest key, as this references the cart that is most up to date.
The base URL for the REST API is https://secure.ecster.se/rest/ for production environment. For test environment use https://labs.ecster.se/rest/. In addition to the authorization headers below, you also need to send the correct content type (application/json) for JSON, as this is the data format for the API.
The authorization contains three headers which are described below. The username and password is obtained by creating a test account. Once you’ve submitted the form, you’ll receive an email from us containing the information you need.
X-Ecster-origin: checkout
X-Ecster-username: <shop username>
X-Ecster-password: <shop password>
Read more about implementing request header in the Get started section.
POST /eps/v1/cart
Once the customer enters the store checkout page, you need to execute Create cart. This will return a cart key which you need to initiate Ecster Pay in your application's frontend.
You need to somehow persist your cart key in your frontend as it is a mandatory parameter to the Update cart call.
The parameters required to execute Create cart are visible if you expand the example. You can also refer to Get started to get a good introduction.
You can choose if you want to send in delivery method in Create cart as an own object or as a cart row. NOTE: If you send in delivery methods as an own object you have to mark one as selected.
X-Ecster-origin: checkout
X-Ecster-username: <username>
X-Ecster-password: <password>
Content-Type: application/json
{
"locale": {
"language": "sv",
"country": "SE"
},
"deliveryMethods": [
{
"id": "1a2c681f-7d88-425a-a3f7-cda2bbfc91cd",
"name": "Hemleverans",
"description": "Leverans till ditt hem.",
"price": 4900,
"selected": true
}
],
"cart": {
"amount": 27800,
"currency": "SEK",
"message": null,
"externalReference": null,
"rows": [
{
"partNumber": "264275-0044_501",
"name": "Vit T-shirt",
"description": "Vit 100% bomull",
"quantity": 2.0,
"unitPrice": 13900,
"unit": "st",
"vatCode": "25%",
"discount": 0,
"serials": [
"264275"
]
}
]
},
"eCommercePlatform": {
"reference": "2cc5c43d-fb92-472f-828a-1a5ad703d512",
"info": "info about version"
},
"customer": null,
"returnInfo": {
"ok": "<url to shop>"
},
"notificationUrl": null
}
{
responseTime: 100
status: 201,
response: {
key: 'cart key'
}
}
See data type locale
An array of delivery methods. See data type delivery method.
See data type cart
See data type customer
Notification URL for OSN
E-Commerce Platform information
Only used for external Ecster Pay
language code (ISO-639) ”sv”, ”en”, ”no”, ”da”, ”fi”
country code (ISO-3166), "SE"
Order amount in least valued denomination
Currency - SEK
Shop order reference
Shop item identifier
Amount in least valued denomination (öre, cent...)
E.g. st, kg, cm...
0% | 6% | 12% | 25%
Discount in least valued denomination
Item serial numbers
Country specific format, e.g. YYMMDD-XXXX
Price in the least valued denomination (öre, cent e.t.c.)
indicates if this option should be pre selected
Unique identifier provided by Ecster Pay
Info about version
Return URL back to shop
PUT /eps/v1/cart/<cart key>
If the customer adds items to the cart after Ecster Pay has started on the checkout page, you'll need to execute Update cart. The parameters are similar to Create cart, but you also need to provide the current cart key. If it’s the first time you execute Update cart, you will use the current cart key from the Create cart call. After a successful update, a new cart key will be returned to your system. Save this cart key as this is now the current active cart key.
You can choose if you want to send delivery method in Update cart as an own object or as a cart row. NOTE: If you send in delivery methods as an own object you have to mark one as selected.
X-Ecster-origin: checkout
X-Ecster-username: <username>
X-Ecster-password: <password>
Content-Type: application/json
The most recent cart key.
{
"locale": {
"language": "sv-SE",
"country": "SE"
},
"deliveryMethods": [
{
"id": "b7547b2f-96bf-4e1e-8854-6ab638290ac9",
"name": "Hemleverans",
"description": "Leverans till ditt hem.",
"price": 4900,
"selected": true
}
],
"cart": {
"amount": 44700,
"currency": "SEK",
"message": null,
"externalReference": null,
"rows": [
{
"partNumber": "217844-0040_501",
"name": "Vit T-shirt",
"description": "Vit 100% bomull",
"quantity": 2.0,
"unitPrice": 14900,
"unit": "st",
"vatCode": "25%",
"discount": 0,
"serials": [
"264275"
]
},
{
"partNumber": "217844-0040_502",
"name": "Svart T-shirt",
"description": "Svart 100% bomull",
"quantity": 1.0,
"unitPrice": 14900,
"unit": "st",
"vatCode": "25%",
"discount": 0,
"serials": [
"264276"
]
}
]
},
"eCommercePlatform": {
"reference": "2cc5c43d-fb92-472f-828a-1a5ad703d512",
"info": "info about version"
},
"customer": null,
"returnInfo": {
"ok": "<url to shop>"
},
"notificationUrl": null
}
{
responseTime: 100
status: 201,
response: {
key: 'cart key'
}
}
Only used for external Ecster Pay
language code (ISO-639) ”sv”, ”en”, ”no”, ”da”, ”fi”
country code (ISO-3166), "SE"
Price in the least valued denomination (öre, cent e.t.c.)
indicates if this option should be pre selected
Order amount in least valued denomination
Currency - SEK
Shop order reference
Shop item identifier
Amount in least valued denomination (öre, cent...)
E.g. st, kg, cm...
0% | 6% | 12% | 25%
Discount in least valued denomination
Item serial numbers
Country specific format, e.g. YYMMDD-XXXX
Unique indentifier provided by Ecster Pay
Info about version
Return URL back to shop
GET /orders/v1/<internalReference>
There’s potentially a lot of information that the customer provides in the checkout process that’s not directly available to your site. If the customer provides the address in the external checkout, it won’t be available to your site during the checkout process. It is the same when using the integrated Ecster Pay. Since the customer provides information within an iframe, it will not be available to your site. In this case, there are callbacks you can utilize to get some information during the checkout process. However, in order for you to get a complete order summary, there’s a REST API function called Get order.
This function is typically called when Ecster Pay calls your site through the Order status notification (OSN). When a customer completes a payment, Ecster Pay will call the URL provided in notification URL in Create cart.
You must provide the internal order reference in the URL when making the call.
X-Ecster-origin: checkout
X-Ecster-username: <shop username>
X-Ecster-password: <shop password>
Content-type: application/json
The internal order reference from OSN
{
"responseTime":52,
"status":200,
"response":{
"order":{
"idMethod":"BANKID_MOBILE",
"amount":44700,
"currency":"SEK",
"rows":[
{
"partNumber":"264275-0044_501",
"name":"Vit T-shirt",
"description":"Vit 100% bomull",
"quantity":2.0,
"unitPrice":13900,
"unit":"st",
"vatCode":"25%",
"discount":0,
"serials":[
"264275"
]
},
{
"partNumber":"264275-0044_502",
"name":"Svart T-shirt",
"description":"Svart 100% bomull",
"quantity":1.0,
"unitPrice":13900,
"unit":"st",
"vatCode":"25%",
"discount":0,
"serials":[
"264276"
]
}
],
"externalReference":"TMP604",
"debitedAmount":0,
"creditedAmount":0,
"internalReference":"pNRpI7KtqHwMx4zU",
"status":"ready",
"date":"2016-06-17T11:43:34.124+02:00"
},
"customer":{
"id":10182,
"ssn":"670704-0082",
"name":"BERGLUND, BERFIN",
"address":"HAMMARBERGSGATAN 13",
"city":"FINSPÅNG",
"zip":"612 41",
"cellular":"0700000000",
"email":"email@email.se"
},
"deliveryMethod":{
"id":"1a2c681f-7d88-425a-a3f7-cda2bbfc91cd",
"name":"Hemleverans",
"description":"Leverans till ditt hem.",
"price":4900,
"selected":true
},
"paymentMethod":{
"type":"CARD",
"sortOrder":0,
"terms":[
{
"cardBrand":"MASTER"
}
]
},
"transactions":[
{
"type":"ORIGINAL",
"amount":44700,
"closeOrder":false,
"rows":[
{
"partNumber":"264275-0044_501",
"name":"Vit T-shirt",
"description":"Vit 100% bomull",
"quantity":2.0,
"unitPrice":13900,
"unit":"st",
"vatCode":"25%",
"discount":0,
"serials":[
"264275"
]
},
{
"partNumber":"264275-0044_502",
"name":"Svart T-shirt",
"description":"Svart 100% bomull",
"quantity":1.0,
"unitPrice":13900,
"unit":"st",
"vatCode":"25%",
"discount":0,
"serials":[
"264276"
]
}
],
"created":"2016-06-17T11:43:34.123+02:00"
}
]
}
}
See Order object
See Customer object
See Recipient object
See Delivery method object
See Payment method object
See Transactions object
Order amount in least valued denomination
Currency - SEK, NOK, EUR...
Shop order reference
Ecster internal order reference
Country specific format, e.g. YYMMDD-XXXX
Recipient object, that contians information of the current customer. The customer have chosen to use an alternative address from their registered address.
Name of the current customer.
Address of the current customer.
Example C/O adress, company name
Street name is only available with country code DE and AT
Street number is only available with country code DE and AT
Zip/Area code of the current customer.
City location of current customer.
Country code format ISO 3166-1 alpha-2
Price in the least valued denomination (öre, cent e.t.c.)
indicates if this option should be pre selected
See Payment method terms
See object Payment provider
Number of part payments
Amount to pay per month using part payment
See transaction row
A date in ISO 8601 format with timezone information
Contains a description of the current order row.
Percentage of discount that is used in the current order row.
Name of the current order row.
Shop's item identifier.
Quantity of the current order row.
Array of item serial numbers.
Provides information about what unit that is measured.
Price of the current order row.
The value added tax for the current order row.
POST /orders/v1/<internalReference>/externalReference
Creates an external order reference for a specific order if it does not exist or updates an existing external reference if does exist.
X-Ecster-origin: checkout
X-Ecster-username: <shop username>
X-Ecster-password: <shop password>
Content-type: application/json
Internal reference
{
"externalReference": "<Shop_order_reference>"
}
{
responseTime: 100,
status: 200
}
Whenever an order changes status, e.g. READY, Ecster Pay communicates this back to your site. This function is called Order status notification (OSN). Ecster Pay will call an URL determined by the parameter notification URL provided in createCart.
You will need to create a web service that Ecster Pay communicates with. Ecster Pay will execute a POST request containing the internal and external order references as well as the new order status. Use the internal order reference to get order details from Ecster Pay.
If your site successfully received and processed the call from Ecster Pay, you must return HTTP status 200 OK. Otherwise, Ecster Pay will retry the call every other hour for 48 hours.
{
internalReference: '9VVacR2X15uHV1dk', // Ecster Pay order ref
externalReference: 'PO1000', // as sent from create order
status: 'READY'
}
Reference in Ecster
Shop reference (as provided via Create order)
Maximum value 16 characters
Orderstatus | Description |
Ready (“ready”) | The order is ready to be delivered by the store. |
Awaiting contract (“awaitingContract”) | The order is approved and Ecster awaits signed customer contract, order cannot be delivered by store. |
Awaiting payment ("awaitingPayment") |
The order is being processed. |
Denied (“denied”) | The order was denied and cannot be delivered. |
Failed (“failed”) | The order failed payment. |
Aborted (“aborted”) | The customer aborted the payment. |
Partly delivered (“partiallyDelivered”) | The store has delivered part of the order and can deliver the rest of the order at any time. |
Fully delivered (“fullyDelivered”) | The store has delivered a complete order or closed a part delivered order. The store cannot deliver the order. |
Annuled (“annuled”) | The store has annuled the order and cannot deliver the order. |
Expired (“expired”) | The order is too old. |
Blocked (“blocked”) | The order is stopped by Ecster. This happens for example when Ecster suspects that the order is fraudulent. |
Manual handling (“manualHandling”) | The order is manually beeing handled by Ecster. |
To be able to run Ecster Pay, the following script has to be included on the page where Ecster Pay is going to be used.
https://secure.ecster.se/pay/integration/ecster-pay.js
<script src="https://secure.ecster.se/pay/integration/ecster-pay.js"></script>
https://labs.ecster.se/pay/integration/ecster-pay-labs.js
<script src="https://labs.ecster.se/pay/integration/ecster-pay-labs.js"></script>
The start method is used to render Ecster Pay in the container on your store checkout page.
View the example below to see all options you can pass to this function. The parameters cartKey and shopTermsUrl are required.
Used to set configuration of the EcsterPay script API in the start call.
The cartKey value received from the Ecster Pay REST API create cart call
Url to the terms of purchase page, link is displayed before the purchase button in the checkout.
Whether to show the cart in a integrated checkout or not.
Decides wether the success page is displayed in EcsterPay frame or not. Default is false which means that the result will not be presented in Ecster Pay frame.
true - Ecster Pay will show a success page within the Ecster Pay iframe
false - shop is responsible for removing the iframe and show a success page when onPaymentSuccess is received.
Event that is called when the before onCheckoutStartSuccess
Event that is called when ecster service has been successfully started
Events that runs if the Ecster service fails to start.
Event when the delivery method is changed.
Event when delivery address is changed, see more info about the newDeliverAddress object.
Event that is called when the payment is successfully executed.
An event that’s trigged when the payment failed to execute.
Event that is called when the payment is denied.
Event thats triggerd when the checkout before the update of the checkout is started, can be used to assert that the user interface is locked for changes.
Event that is triggerd if the update of the checkout is successful.
Event that triggers when the update of the checkout failed.
An event that’s trigged before the checkout starts.
BEST PRACTICE: While starting Ecster Pay, we recommend that you prevent the customer from making any changes to the cart. Read more under locking mechanism.
An event that’s trigged when Ecster Pay successfully started.
An event that’s trigged when the checkout failed to start.
An event that’s trigged when the delivery address is changed.
NOTE: A new delivery address may render the current delivery method and/or price as invalid. We recommend that you run the logic for choosing delivery method again, then execute update cart with the new values.
The new delivery address is sent as a parameter to the event.
address of the new delivery address object.
Example C/O adress, company name
Street name is only available with country code DE and AT
Street number is only available with country code DE and AT
zip/postal code of the new delivery address
city/postal area of the new delivery address.
Country code format ISO 3166-1 alpha-2
name of the new delivery address.
An event that’s trigged when the contact information is changed.
The new contact information is sent as a parameter to the event.
Cellphone number of the current customer.
An event that´s trigged when the payment has been successfully executed. When triggered, you should update the order in your system accordingly. Furthermore, if Ecster Pay is indicating shop´s own result page (.start and showPaymentResult set to false), you should direct the consumer to your shops result page. Your backend system will receive an OSN request with order status information (asynchronously within a reasonable amount of time, e.g. a few seconds up to 5 minutes). Your backend must be able to handle your order being updated twice, both from the triggered event and from the OSN request, regardless which action happens first.
NOTE: It may occur that the onPaymentSuccess event is not triggered even though the order was successfully executed in Ecster Pay, e.g. if the consumer closes the browser. In this case you should update the order in your system upon receiving the OSN request.
Current order object of the successful payment.
the payment method of the current successful payment.
contains information about the customer on the current successful payment.
Recipient object, that contains information of the current customer. The customer have chosen to use an alternative address from their registered address.
Contains Ecsters internal order reference.
Shows paymentmethod fee
the order object that will be passed from EcsterPay to you.
Amount of the current order.
What currency the current order.
Array of order rows containing the items of the current order.
Can contain a message about the order.
Contains a reference to the shop where to purchase has been made.
Contains a list of order rows.
Shop's item identifier.
Name of the current order row.
Contains a description of the current order row.
Quantity of the current order row.
Price of the current order row.
Provides information about what unit that is measured.
The value added tax for the current order row.
Percentage of discount that is used in the current order row.
Array of item serial numbers.
Customer object, that contains information of the current customer.
Social security number of the current customer, will be provided with country specific format(YYMMDD-XXXX).
Name of the current customer.
Address of the current customer.
City location of current customer.
Zip/Area code of the current customer.
Cellphone number of the current customer.
Email address of the current customer.
Recipient object, that contains information of the current customer. The customer have chosen to use an alternative address from their registered address.
Name of the current customer.
Address of the current customer.
Example C/O adress, company name
Street name is only available with country code DE and AT
Street number is only available with country code DE and AT
Zip/Area code of the current customer.
City location of current customer.
Country code format ISO 3166-1 alpha-2
Show paymentmethod fee
Shows paymentmethod fee
An event that’s trigged when the payment has failed.
NOTE: It may occur that the onPaymentFailure event is not triggered even though the order process was completed in Ecster Pay, e.g. if the consumer closes the browser. In this case you should update the order in your system upon receiving the OSN request.
An event that’s trigged when the payment was denied by the payment service.
NOTE: It may occur that the onPaymentDenied event is not triggered even though the order process was completed in Ecster Pay, e.g. if the consumer closes the browser. In this case you should update the order in your system upon receiving the OSN request.
Current order object of the denied payment.
the payment method of the current denied payment.
contains information about the customer on the current denied payment.
the order object that will be passed from EcsterPay to you.
Amount of the current order.
What currency the current order.
Array of order rows containing the items of the current order.
Can contain a message about the order.
Contains a reference to the shop where to purchase has been made.
Contains a list of order rows.
Shop's item identifier.
Name of the current order row.
Contains a description of the current order row.
Quantity of the current order row.
Price of the current order row.
Provides information about what unit that is measured.
The value added tax for the current order row.
Percentage of discount that is used in the current order row.
Array of item serial numbers.
Customer object, that contains information of the current customer.
Social security number of the current customer, will be provided with country specific format(YYMMDD-XXXX).
Name of the current customer.
Address of the current customer.
City location of current customer.
Zip/Area code of the current customer.
Cellphone number of the current customer.
Email address of the current customer.
An event that executes before the update of Ecster Pay starts.
BEST PRACTICE: While updating Ecster Pay, we recommend that you prevent the customer from making any changes to the cart. Read more under locking mechanism.
An event that's trigged when the update of Ecster Pay has been successfully executed.
An event that’s trigged when the update of Ecster Pay has failed to execute.
An event that's triggered when the customer has completed a successful BankID authentication.
NOTE: This is where you can communicate with this particular customer by, for example, presenting the customer with certain discounts or bonuses.
Contains information about the customer who has completed a successful BankID authentication.
Customer object, that contains information of the current customer.
Social security number of the current customer, will be provided with country specific format(YYMMDD-XXXX).
Address of the current customer.
City location of current customer.
Zip/Area code of the current customer.
Cellphone number of the current customer.
Email address of the current customer.
Name of the current customer.
Ecster Pay must be notified when the cart is going to be updated. Use the initUpdateCart function in the Ecster Pay JS API.
First call initUpdateCart with the current cart key in your application’s frontend. The initUpdateCart call returns a callback function.
Then execute initUpdateCart containing the updated information through your application’s backend to receive a new cart key.
Finally execute the callback function with the new cart key. This will cause Ecster Pay to be refreshed with the new information.
(function(window, $) {
var currentCartKey = '<cart key>';
var updatedCartCallback = EcsterPay.initUpdateCart(currentCartKey);
$.post('<Url to update API>', function(newCartKey) {
updatedCartCallback(newCartKey);
currentCartKey = newCartKey;
})
})(window, jQuery)
BEST PRACTICE: While updating Ecster Pay, we recommend that you prevent the customer from making any changes to the cart. Read more under locking mechanism.
DEPRECATED: .updateCart(currentCartKey)
This function generates a URL to the external Ecster Pay. This is the fastest way to implement Ecster Pay. See this tutorial for a complete implementation.
DEPRECATED: .getNewWindowUrl(options)
The options that are provided to generate the external checkout window.
The cartKey obtained in createCart or updateCart is required.
Enables the cart in the external checkout window.
Enables the delivery options in the external checkout window.
Link to the shop terms needs to be provied to send the user to the correct terms of purchase.