Events
A system based on CustomEvent API is available. You can use those methods, available in paygreenjs
:
Name | Type | Description |
---|---|---|
on | func | Subscribe to an event and attach a callback |
off | func | Detach your callback from an event |
Events | EventsType | Constant giving all events available |
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.on(paygreenjs.Events.TOKEN_READY, (event) => {
console.log('TOKEN_READY', event.detail);
});
List of Events
You can check the events from the auto-generated documentation here
Name | Description |
---|---|
ACTUAL_FLOW_PAYMENT_DONE | Trigger when the actual payment is done (successfull or not). Only triggered if there is a rest to pay. |
AUTHENTICATION_FLOW_START | Trigger when authentication flow start (3DS, OAUTH ...) |
CARD_ONCHANGE | Trigger CARD change, return detail object with validity of the card |
CVV_FIELD_FULFILLED | Trigger if CVV is FULFILLED and valid (doesn't work with bank_card svad) |
CVV_FIELD_ONCHANGE | Trigger if CVV is changed, return detail object with validity and potential error (doesn't work with bank_card svad) |
ERROR | Trigger if an error occured, return Error. |
EXP_FIELD_FULFILLED | Trigger if EXP is FULFILLED and valid (doesn't work with bank_card svad) |
EXP_FIELD_ONCHANGE | Trigger if EXP is changed, return detail object with validity and potential error (doesn't work with bank_card svad) |
FULL_PAYMENT_DONE | Trigger when the whole Payment Order has been payed. |
INSTRUMENT_READY | Trigger when Instrument has been created |
ON_OPEN_POPUP | Trigger when a open pop must be open, provide the url |
PAN_FIELD_FULFILLED | Trigger if PAN is FULFILLED and valid (doesn't work with bank_card svad) |
PAN_FIELD_ONCHANGE | Trigger if PAN is changed, return detail object with validity and potential error (doesn't work with bank_card svad) |
PAYMENT_FAIL | Trigger when the payment authorization has been refused. |
PAYMENT_FLOW_ONCHANGE | Trigger when the actual payment flow changed |
REQUEST_SUBMIT_TOKENIZE_FORM | Trigger to submit tokenize form |
REUSABLE_ALLOWED_CHANGE | Trigger when the user change Reusable Checkbox state. Or when you use the paygreenjs.updateConsent(boolean) function |
TOKEN_FAIL | Trigger if the tokenize fail, return error value that detail why the tokenize fail. |
TOKEN_READY | Trigger when the token is ready, return the token string. |
TOKEN_DETAILS_READYDepecrated | Depecrated Trigger when the token is ready and these details like issue, return the token in 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.on(paygreenjs.Events.PAN_FIELD_ONCHANGE, (event) => {
console.log('PAN_FIELD_ONCHANGE', event.detail);
});
Updated about 2 months ago