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 onPaymentCompleted, 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs should be used in your solution.

onPaymentCompleted

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

onPaymentCompleted 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs should be used in your solution.
redirectUrl string The URI the user will be redirect to after a completed payment.

onPaymentCanceled

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

onPaymentCanceled 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs should be used in your solution.
redirectUrl string The URI 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs should be used in your solution.
redirectUrl string The URI the user will be redirect to after a failed payment.

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
{
    "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 URI 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.
     

onPaymentMenuInstrumentSelected

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

onPaymentMenuInstrumentSelected 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs 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 URI and unique identifier of the payment resource . Please read about URI Usage to understand how this and other URIs should be used in your solution.
details string A human readable and descriptive text of the error.

onExternalRedirect

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

onExternalRedirect event object

1
2
3
{
    "redirectUrl": "https://external.example.com/"
}
Field Type Description
redirectUrl string The URI 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.