A system based on CustomEvent API is available. You can use those methods, available in paygreenjs:

NameTypeDescription
attachEventListenerfuncSubscribe to an event and attach a callback
detachEventListenerfuncDetach your callback from an event
EventsEventsTypeConstant giving all events available

You can check the events here

The events returned are of type CustomEvent. If it's provided, you can check the attribut detail giving more informations (like detailled errors, tokens...)

Here it is an example:

paygreenjs.attachEventListener(paygreenjs.Events.TOKEN_READY, (event) => {
	console.log('TOKEN_READY', event.detail);
});

OnChange

Paygreenjs is providing some onChange events, giving you the possibility to get some data when an input change. Please refer to the Events constant to check all available onChange events.

Here it is an example:

paygreenjs.attachEventListener(paygreenjs.Events.TOKEN_READY, (event) => {
	console.log('PAN_FIELD_ONCHANGE', event.detail);
});