Event capture
This page provides instructions on how to get events generated by the Cashier in asynchronous mode.
As an alternative to the notifications, you can configure your ecosystem to "listen to", i.e. receive, transaction-related events generated by the Cashier. This might be necessary for implementing your own business logic when BridgerPay cannot control the redirection.

Events

Consult the Cashier or server-side deposit flow diagram for better understanding the sequence of the events.
Session created: the API has created or failed to create a Cashier session.
1
[bp]:create-session //or
2
[bp][cashier:{{cashierKey}}]:create-session
Copied!
1
{
2
type: 'success' | 'failure',
3
bearerToken?: [string]
4
}
Copied!
Cashier widget shown: a Cashier widget has been shown to a shopper.
1
[bp]:contentRendered //or
2
[bp][cashier:{{cashierKey}}]:contentRendered
Copied!
Deposit processed: the shopper's request to make a deposit has been processed. This might be approved or declined, or the PSP might request to enter a security code to confirm the deposit (3D Secure). In the latter case, the event will happen at the end of the workflow.
1
[bp]:deposit //or
2
[bp][cashier:{{cashierKey}}]:deposit
Copied!
1
{
2
type: 'approved' | 'declined' | 'pending'
3
}
Copied!
Shopper redirected: the shopper has been redirected to the appropriate page to see the result of their transaction.
1
[bp]:redirect //or
2
[bp][cashier:{{cashierKey}}]:redirect
Copied!
1
{
2
url: [string]
3
}
Copied!

Implementation

If a Cashier scheme is integrated as a script embedded in your website, include the following piece of code to listen to all the event.
1
window.addEventListener(
2
'[bp]:all',
3
({ detail }) => console.log('[bp]:all', detail)
4
);
Copied!
Or, include the following one to listen to a particular event (e.g. "Session created").
1
window.addEventListener(
2
'[bp]:create-session',
3
({ detail: { type, bearerToken } }) => console.log(
4
'[bp]:create-session',
5
type,
6
bearerToken
7
)
8
);
Copied!
If a Cashier scheme is integrated as an iFrame placed on an arbitrary web resource, include the following piece of code to listen to the events.
1
window.addEventListener(
2
'message',
3
({ data: { event, url }}) => {
4
if (!event || !event.includes('[bp]'))
5
return;
6
if (event === '[bp]:redirect')
7
window.location.href = url;
8
}
9
);
Copied!
Last modified 1mo ago
Copy link