Payment Menu v2

Seamless View Events

Possible events during Seamless View payments.

Edit "Seamless View Events" on GitHub

Payment Menu Events

During operation in the Payment Menu, several events can occur. They are described below.

info

Event Overrides: Adding an event handler to one of the following events overrides the default event handler, meaning your custom event handler will have to do what the default event handler did. If you don’t, the behavior of the event is going to be undefined. Just adding an event handler for logging purposes is therefore not possible, the event handler will have to perform some functionality similar to the event handler you are overriding.

onApplicationConfigured

This event triggers whenever a reconfiguration leads to resizing of the payment menu. No action will be done if callback is not set. The onApplicationConfigured event is raised with the following event argument object:

onApplicationConfigured event object

1
2
3
4
5
6
{
    "actionType": "OnApplicationConfigured",
    "bodyHeight": "[clientHeight of iframe content]",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "source": "PaymentMenuCore"
}
Field Type Description
actionType string The type of event that was raised.
bodyHeight string The height of the client’s iframe content.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
source string The source of the reconfiguration

onError

This event triggers during terminal errors or if the configuration fails validation. The onError event will be raised with the following event argument object:

onError event object

1
2
3
4
5
6
{
    "bodyType": "OnError",
    "details": "English descriptive text of the error",
    "origin": "paymentorders",
    "paymentOrderId:": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
bodyType string The type of event that was raised.
details string A human readable and descriptive text of the error.
origin string paymentorders, identifies the system that originated the error.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.

onExternalRedirect

This event triggers when a user is redirected to a separate web page, like 3D-Secure or BankID signing.

Subscribe to this event if it’s not possible to redirect the payer directly from within Swedbank Pay’s payment frame.

If no callback method is set, you will be redirected to the relevant url. It will be raised with the following event argument object:

onExternalRedirect event object

1
2
3
4
5
{
    "actionType": "OnExternalRedirect",
    "paymentOrderId:": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/external"
}
Field Type Description
actionType string The type of event that was raised.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
redirectUrl string The external URL where the user will be redirected.

onOutOfViewOpen

Triggered when another tab is opened in the browser, like the information page for onboarding of stored cards, or Swedbank Pay’s owner TOS.

The event cannot be opened as a modal since the payer needs to see that this is a link on Swedbank Pay’s domain.

Subscribe to this event if you do not want the default handling of these links. But e.g. want to redirect the payer to a new page, and not just another tab within the same browser.

If no callback method is set, the url will be opened in a new tab. It will be raised with the following event argument object:

onOutOfViewOpen event object

1
2
3
4
5
{
    "actionType": "OnOutOfViewOpen",
    "openUrl": "https://example.com/external",
    "paymentOrderId:": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
actionType string The type of event that was raised.
openUrl string The external URL where the user will be redirected.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.

onPaymentCanceled

This event triggers when the payer aborts the purchase from the payment menu. As the Seamless View payment menu doesn’t have a cancel button (present in the Redirect integration), you need to provide this button for the payer at your end. When the payer presses the cancel button, we recommend sending an API request aborting the payment so it can’t be completed at a later time. When we receive the request, an abort event will be raised the next time the UI fetches information from the server. Because of that, you should also refresh after aborting, as this will trigger the event.

It will be raised with the following event argument object:

onPaymentCanceled event object

1
2
3
4
5
6
{
    "actionType": "OnPaymentCanceled",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/cancelled"
}
Field Type Description
actionType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
redirectUrl string The URL the user will be redirect to after a cancelled payment.

onPaymentCompleted

This event triggers when the payer successfully completes or cancels the payment.

Subscribe to this event if actions are needed on you side other than the default handling of redirecting the payer to your completeUrl. Call GET on the paymentOrder to receive the actual payment status, and take appropriate actions according to it.

It will be raised with the following event argument object:

onPaymentCompleted event object

1
2
3
4
5
6
{
    "actionType": "OnPaymentCompleted",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/success"
}
Field Type Description
actionType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
redirectUrl string The URL the user will be redirect to after completing the payment.

onPaymentCreated

Triggered when the payer has selected a payment method and actively attempts to perform a payment.

The onPaymentCreated event is raised with the following event argument object:

onPaymentCreated event object

1
2
3
4
5
6
{
    "bodyType": "OnPaymentCreated",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "instrument": "creditcard",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
bodyType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
instrument string Creditcard, vipps, swish, invoice. The method selected when initiating the payment.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.

onPaymentFailed

Triggered when a payment has failed, disabling further attempts to perform a payment.

The onPaymentFailed event is raised with the following event argument object:

onPaymentFailed event object

1
2
3
4
5
6
{
    "actionType": "OnPaymentFailed",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/failed"
}
Field Type Description
actionType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
redirectUrl string The URL the user will be redirect to after a failed payment.

onPaymentMenuInstrumentSelected

This event triggers when a user actively changes payment method in the Payment Menu.

Subscribe to this event if actions, e.g. showing an information text, are required on your side if the payer changes payment method.

If no callback method is set, no handling action will be done. It will be raised with the following event argument object:

onPaymentMenuInstrumentSelected event object

1
2
3
4
5
{
    "bodyType": "OnPaymentMenuInstrumentSelected",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "instrument": "creditcard | vipps | swish | invoice"
}
Field Type Description
bodyType string The type of event that was raised.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
instrument string Creditcard, vipps, swish, invoice. The method selected by the user.

onPaymentPending

Triggered when a payment enters a paying state ( Sale, Authorize, Cancel, etc).

Read more about these events below.

onPaymentPending event object

1
2
3
4
5
{
    "bodyType": "OnPaymentPending",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
bodyType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.

onPaymentToS

This event triggers when the user clicks on the “Display terms and conditions” link. The onPaymentToS event is raised with the following event argument object:

onPaymentToS event object

1
2
3
4
5
6
{
    "actionType": "OnPaymentToS",
    "openUrl": "https://example.com/terms-of-service",
    "origin": "Merchant",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
actionType string The type of event that was raised.
openUrl string The URL containing Terms of Service and conditions.
origin string owner, merchant. The value is always Merchant unless Swedbank Pay hosts the view.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.

onPaymentTransactionFailed

This event triggers when a payment attempt fails, further attempts can be made for the payment.

An error message will appear in the payment UI, and the payer will be able to try again or choose another payment method. The onPaymentTransactionFailed event is raised with the following event argument object:

onPaymentTransactionFailed event object

1
2
3
4
5
6
{
    "bodyType": "OnPaymentTransactionFailed",
    "id": "/psp/{instrument}/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "paymentOrderId": "/psp/paymentorders/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "details": "[HttpCode ProblemTitle]"
}
Field Type Description
bodyType string The type of event that was raised.
id string The relative URL and unique identifier of the payment resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
paymentOrderId string The relative URL and unique identifier of the paymentOrder resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
details string A human readable and descriptive text of the error.

Updating Payment Menu

When the contents of the shopping cart changes or anything else that affects the amount occurs, the paymentorder must be updated and the Payment Menu must be refreshed.