Payment Menu

Payment Menu Events

schedule 5 min read

Possible events during Payment Menu payments

Edit "Payment Menu 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 behaviour 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.

onPaymentPending

This events triggers when a payment enters a paying state ( Sale, Authorize, Canceletc). The onPaymentPending event will be followed by either onPaymentPaid, onPaymentFailed or onPaymentTransactionFailed based on the result of the payment. Read more about these events below.

onPaymentPending event object

1
2
3
{
    "id": "/psp/paymentorders/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1"
}
Field Type Description
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.

onPaymentPaid

This event triggers when a payment has completed successfully. The onPaymentPaid event is raised with the following event argument object:

onPaymentPaid event object

1
2
3
4
{
    "id": "/psp/paymentorders/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/complete"
}
Field Type Description
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.
redirectUrl string The URL the user will be redirect to after a completed payment.

onPaymentAborted

This event triggers when the user cancels the payment. The onPaymentAborted event is raised with the following event argument object:

onPaymentAborted event object

1
2
3
4
{
    "id": "/psp/paymentorderspayments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/canceled"
}
Field Type Description
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.
redirectUrl string The URL the user will be redirect to after a canceled payment.

onPaymentFailed

This event triggers 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
{
    "id": "/psp/paymentorders/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "redirectUrl": "https://example.com/failed"
}
Field Type Description
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.
redirectUrl string The URL the user will be redirect to after a failed payment.

onTermsOfServiceRequested

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

onTermsOfServiceRequested event object

1
2
3
4
{
    "origin": "owner",
    "openUrl": "https://example.com/terms-of-service"
}
Field Type Description
origin string owner, merchant. The value is always merchant unless Swedbank Pay hosts the view.
openUrl string The URL containing Terms of Service and conditions.

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
{
    "origin": "paymentorders",
    "messageId": "ec2a9b09-601a-42ae-8e33-a5737e1cf177",
    "details": "Descriptive text of the error"
}
Field Type Description
origin string paymentorders, identifies the system that originated the error.
messageId string A unique identifier for the message.
details string A human readable and descriptive text of the error.
     

onBillingDetailsAvailable

This event triggers when a consumer has been identified. The onBillingDetailsAvailable event will be raised with the following event argument object:

onBillingDetailsAvailable event object

1
2
3
4
{
    "actionType": "OnBillingDetailsAvailable",
    "url": "/psp/consumers//billing-details",
}
Field Type Description
actionType string The type of event that was raised.
url string The URL containing billing details.

onShippingDetailsAvailable

This event triggers when a consumer has been identified or their shipping address has been updated. The onShippingDetailsAvailable event will be raised with the following event argument object:

onShippingDetailsAvailable event object

1
2
3
4
{
    "actionType": "OnShippingDetailsAvailable",
    "url": "/psp/consumers//shipping-details",
}
Field Type Description
actionType string The type of event that was raised.
url string The URL containing shipping details.

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:

onEventNotification event object

1
2
3
{
    "details": "source: "PaymentMenuClient", bodyHeight: "[clientHeight of iframe content]""
}
Field Type Description
details string The source of the reconfiguration, and the new height of the iframe.

onEventNotification

This event triggers whenever any other public event is called. It does not prevent their handling. The onEventNotification event is raised with the following event argument object:

onEventNotification event object

1
2
3
{
    "details": "Name of the event called"
}
Field Type Description
details string A human readable and descriptive text with the event name.

onInstrumentSelected

This event triggers when a user actively changes payment instrument in the Payment Menu. The onInstrumentSelected event is raised with the following event argument object:

onInstrumentSelected event object

1
2
3
4
{
    "name": "menu identifier",
    "instrument": "creditcard | vipps | swish | invoice",
}
Field Type Description
name string The name and identifier of specific instrument instances - i.e. if you deploy more than one type of credit card payments, they would be distinguished by name.
instrument string Creditcard, vipps, swish, invoice. The instrument selected by the user.

onPaymentCreated

This event triggers when a user has selected a payment instrument 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
{
    "id": "/psp/paymentorders/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "instrument": "creditcard",
}
Field Type Description
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 instrument selected when initiating the payment.

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 instrument. The onPaymentTransactionFailed event is raised with the following event argument object:

onPaymentTransactionFailed event object

1
2
3
4
{
    "id": "/psp/paymentorders/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "details": "[HttpCode ProblemTitle]"
}
Field Type Description
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.
details string A human readable and descriptive text of the error.

onOutOfViewRedirect

This event triggers when a user is redirected to a separate web page, for example 3-D Secure or Bank ID signing. The onOutOfViewRedirect event is raised with the following event argument object:

onOutOfViewRedirect event object

1
2
3
{
    "redirectUrl": "https://external.example.com/"
}
Field Type Description
redirectUrl string The URL which the user will be redirected to when a third party requires additional data.

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.