Create a session
Before rendering the components, your backend must create a session. This returns a session ID and the script URL for the components.Base URLs
| Environment | Base URL |
|---|---|
| Production | https://api.checkout.prod.resurs.cloud/payment/public/v1 |
| Mock | https://api.checkout.int.resurs.cloud/mock/payment/public/v1 |
Steps
Obtain a JWT access token
Request a JWT from the Merchant API.POST /oauth2/token (See Merchant API documentation for details.)
Fetch stores
In the next step you will need the store id. See Merchant API for information about fetching your store configurations.
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 Request body example with campaign:Response:
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.
Pass the session ID and script URL to your frontend
Your frontend needs two values from the response:
id: The session ID, used as thesession-idattribute on the componentembed.src: The script URL to load the components
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.
Load the script
Use theembed.src value from the session response:
Choose your approach
There are two levels of integration:- Managed: a single drop-in component that fetches payment methods, renders an accordion, and manages selection state for you. Minimal code needed.
- Full Control: a pure content renderer. You fetch data, build the UI layout, and manage state yourself. Maximum flexibility.
| Concern | Managed | Full Control |
|---|---|---|
| Integration effort | Low | High |
| Flexibility | Low | High |
| Component | <resurs-payment-method-selector> | <resurs-payment-method-group> |
| Data fetching | Automatic | You fetch via JS API or REST |
| Accordion UI | Built-in | You handle |
| Selection state | Automatic | You handle |
| Styling the header | Resurs default | Full control |
| Re-fetch on amount change | Automatic | You handle |
Managed: <resurs-payment-method-selector>
Managed: <resurs-payment-method-selector>
Drop in a single tag. The component fetches payment methods, renders an accordion, and manages selection state automatically.
Interactive example
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
session-id | string | Yes | Session ID from the create session endpoint. |
amount | string | Yes | Total purchase amount in minor units (e.g., "5000" = 50.00 kr). |
customer-type | string | No | NATURAL (consumers) or LEGAL (businesses). Defaults to NATURAL. |
Behavior
- Fetches and re-fetches payment methods automatically when attributes change.
- Shows a loading spinner during fetch, an error message on failure.
Currency is determined by the Resurs payment methods configured for the store relative to the session.
Updating
Update the component by setting new attribute values directly on the element. The component re-fetches automatically when attributes change.Full control: <resurs-payment-method-group>
Full control: <resurs-payment-method-group>
Build your own accordion, tabs, or any layout. This component is a pure content renderer; no fetching, no global listeners, and no expand/collapse behavior. You render the title, subtitle, logos, and surrounding UI. The component handles the content area, including regulatory compliance and formatting.Response shape:
You can also wrap the icon in a container and style the surrounding layout:
Fetch payment method groups
- Frontend (JS API)
- Backend (REST API)
Interactive example
Render the components
Props
| Prop | Type | Required | Description |
|---|---|---|---|
data | string | Yes | The internalData value from the payment method group response. |
active | boolean | No | Whether this group is currently selected/visible. Defaults to false. |
selected-id | string | No | The id from the most recent resursPaymentMethodSelected event. Pass this back to complete the controlled round-trip. |
Controlled component pattern
This component is fully controlled; it never mutates its own props. When the user interacts with the component (e.g. picks an installment option), it fires aresursPaymentMethodSelected event. You must pass the id from that event back to the component via the selected-id prop so the UI re-renders with the correct selection.When active becomes true, the component fires an initial resursPaymentMethodSelected event with the default selection. Always handle this event. The id is what you pass to the Merchant API when creating a payment.Payment method icon
<resurs-payment-method-icon> renders the brand icon for a given payment method. Pass a payment method type via the type attribute and the component displays the corresponding logo.Payment method type, from
typein the payment methods group response. If an unsupported type is passed, a warning is logged to the console and no icon is rendered.Resurs payment methods
| Name | Icon | Type |
|---|---|---|
| Invoice | RESURS_INVOICE | |
| Part payment (select later) | RESURS_PART_PAYMENT_SELECT_LATER | |
| Part payment (select now) | RESURS_PART_PAYMENT_SELECT_NOW | |
| Resurs Card | RESURS_CARD | |
| Revolving Credit | RESURS_REVOLVING_CREDIT | |
| New Revolving Credit | RESURS_NEW_REVOLVING_CREDIT | |
| Generic | GENERIC | |
| Zero | ZERO |
Third-party payment methods
| Name | Icon | Type |
|---|---|---|
| Swish | SWISH | |
| Trustly | TRUSTLY | |
| Vipps | VIPPS | |
| MobilePay | MOBILEPAY | |
| Visa / Mastercard (CARD) | CARD | |
| Visa / Mastercard (D2I) | D2I | |
| Visa / Mastercard (NETS) | NETS |
Example
Styling
The<resurs-payment-method-icon> component renders SVG logos and can be styled with standard CSS. The SVG scales proportionally, so setting one dimension (e.g. height) and leaving the other as auto keeps the aspect ratio.Custom sizing via inline style
Custom sizing via CSS
Badge-style
Events
resursPaymentMethodSelected
Fires when a payment method is selected. The detail property contains:
resursPaymentMethodDeselected
Fires when a payment method is deselected. The detail property contains { id } for a specific deselection, or null when all methods are deselected.
Theming
CSS custom properties
Accessibility
- The components include ARIA labels and keyboard navigation.
- Use semantic HTML around the components.
- Ensure sufficient color contrast if customizing styles.
JavaScript API reference
The script exposeswindow.resurs with utility functions for programmatic control.
resurs.dispatchSelected(id)
Programmatically select a payment method. Fires the global resursPaymentMethodSelected event.
resurs.dispatchDeselected()
Programmatically deselect all payment methods. Fires the global resursPaymentMethodDeselected event.
Troubleshooting
Component not rendering?
Verify component attributes:session-idmust be a valid session ID from the API.amountmust be set.customer-typemust beNATURALorLEGAL.
- Use
embed.srcfrom the session response. Do not hardcode the URL. - The script must have
type="module".
Session or API errors
“Unauthorized” or 401 errors:- Session is invalid or expired. Create a new session.
- Verify the session ID is the
idvalue from the session response. - Ensure the session hasn’t expired.
Payment method types
The following payment method types are supported:RESURS_INVOICERESURS_PART_PAYMENT_SELECT_LATERRESURS_PART_PAYMENT_SELECT_NOWRESURS_CARDRESURS_REVOLVING_CREDITRESURS_NEW_REVOLVING_CREDIT
Available payment methods depend on your store configuration, customer type,
and the specified amount. Only applicable methods are displayed.