Skip to main content
Before rendering the components, your backend must create a session and your frontend must load the script.

Create a session

Your backend must create a session. This returns a session ID and the script URL for the components.

Base URLs

Steps

1

Obtain a JWT access token

Request a JWT from the Merchant API.POST /oauth2/token (See Merchant API documentation for details.)
2

Fetch stores

In the next step you will need the store id. See Merchant API for information about fetching your store configurations.
3

Create a session

Use the JWT as a bearer token to create a session. The session represents a checkout session and should not be reused between users.
You can pass a campaign keyword in the request body to filter payment methods for a specific campaign (e.g. a promotional offer on a product). When set, only payment methods matching that campaign are returned. When omitted, only non-campaign payment methods are returned.
Campaigns must be configured by Resurs for your payment methods before you can use them. Contact Resurs to set up campaigns.
A request body is always required. When you don’t need campaign filtering, pass an empty JSON object:
Request body example with campaign:
Response:
4

Pass the session ID and script URL to your frontend

Your frontend needs two values from the response:
  • id: The session ID, used as the session-id attribute on the component
  • embed.src: The script URL to load the components
The response also contains expiresAt that states the validity of the session ID. If the session expires, you must create a new session. For normal usage, the session will be long enough so won’t need to refresh.
  • expiresAt: Session expiration timestamp in ISO 8601 format. After this time, the session will no longer be valid for API requests.
Always use embed.src from the session response to load the script. Don’t hardcode the URL.

Load the script

Use the embed.src value from the session response: