Payment Page SDK Events

Allows custom code execution by listening for predefined events occurring within the Cashier SDK.

Initialize

To integrate and use the Praxis Cashier SDK, you must first initialize the PraxisCashier object with the required configuration parameters. This initialization prepares the environment, handles authentication, and defines how the cashier interface will be displayed on your page.

const AUTH_TOKEN = '8a7sd87a8sd778ac961062c6bedddb8'; 
       const CONTAINER = document.getElementById('cashier-block');
       const AUTOCLOSE = false;
       const MODE = 'iframe';
       const LOCALE = 'en-GB';

let cashier = PraxisCashier({
       auth_token: AUTH_TOKEN,  // auth_token received in response to API call
       container: CONTAINER, // block where the cashier iframe or cashier window controls will be added
       autoclose: AUTOCLOSE, // whether to close the cashier window upon transaction attempt
       mode: MODE, // supported values: 'iframe', 'tab', 'window'
       locale: LOCALE // optional, locale for Praxis login button, browser locale is default
}); 

Invoke

To activate the event listener, use the cashier.on() method. This method requires two arguments:

  1. EVENT_TYPE: A string specifying which event you want to monitor (e.g., resize, close, etc.).
  2. function(data){}: A callback function that executes when the specified event is triggered. The data parameter is an object containing relevant information about the event (the content of data varies based on the EVENT_TYPE).
cashier.on(EVENT_TYPE, function(data) {
    // Custom code to execute when the event occurs
    console.log('Event triggered:', data); 
});

//Sample event format
cashier.on('payment_method_selected', function(data) {
      console.log(data.payment_method);
});

Events

The below are the list of available events in Cashier SDK.

These indicators are used in the parameters table to quickly identify the expected state of an attribute in the event context:

SymbolStatusDescription
RequiredThe parameter must be present and contain a valid value.
?OptionalThe parameter may be sent with a valid value or explicitly set to null.
ExcludedThe parameter is reserved for internal processing or future use, and will always appear as null.

cashier_loaded

This event will be sent when the Cashier is loaded successfully. The event context will contain information about the available payment methods and the session information.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "cashier_loaded".
amountdecimal?Predefined amount in Cashier.
currencyvarchar(10)Transaction currency.
payment_methodsarrayList of available payment methods for selection in Cashier.
messagevarchar(100)Results of the operation.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "cashier_loaded",
    "amount": null,
    "currency": "USD",
    "payment_methods": [
        "Credit Card",
        "Default APM",
        "skrill"
    ],
    "message": "Cashier loaded successfully",
    "cid": "2083",
    "order_id": "order_68877"
}

cashier_loading_failed

This event will be sent when the Cashier is not loaded successfully for any reason. The event context will contain a description of the issue.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "cashier_loading_failed".
amountdecimal?Predefined amount in Cashier.
currencyvarchar(10)?Transaction currency.
messagevarchar(100)Results of the operation.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "cashier_loading_failed",
    "amount": 200,
    "currency": "USD",
    "message": "Something went wrong.",
    "cid": "2083",
    "order_id": "order_68877"
}

payment_method_selected

This event will be triggered when the client selects a payment method in Cashier. The event context will contain the selected payment method.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "payment_method_selected".
payment_methodvarchar(50)Selected payment method by the client.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "payment_method_selected",
    "payment_method": "Credit Card",
    "cid": "2083",
    "order_id": "order_68877"
}

payment_methods_loaded

This event will be sent when the payment methods are successfully loaded.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "payment_methods_loaded".
payment_methodsarrayList of available payment methods for selection in Cashier.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "payment_methods_loaded",
     "payment_methods": [
        "Credit Card",
        "Default APM",
        "skrill"
    ],
    "cid": "2083",
    "order_id": "order_68877"
}

client_click

This event will be sent when the client clicks on some elements on the page. The event context will contain the element that was clicked and the page on which the click was made.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "client_click".
elementvarchar(50)The element that was clicked.
pagevarchar(10)The page on which the click was made.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "client_click",
    "element": "currency_field",
    "page": "payment-method",
    "cid": "2083",
    "order_id": "order_68877"
}

resize

This event will be triggered whenever there is a change in the height of the Cashier iframe. The event context will contain the window height size in pixels.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "resize".
heightint(4)The required window height size in pixels (px).
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "resize",
    "height": 348,
    "cid": "2083",
    "order_id": "order_68877"
}

validation_success

This event will be sent when the client entered the data in a valid format and the validation action was successful. The event context will contain the filed name and the value that was entered by the client. This event will be triggered after each observed delay in the input field.

Note: Actual value will not be available for credit card fields.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "validation_success".
fieldvarchar(100)The field filled by the client.
valuevarchar?The value that was entered by the client.
messagevarchar(100)The result of the validation operation.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "validation_success",
    "field": "amount",
    "value": "1",
    "message": "Validation Success",
    "cid": "2083",
    "order_id": "order_68877"
}

validation_failed

This event will be sent when the client entered data in an invalid format and the validation failed. The event context will contain the filed name, the value that was entered by the client, and the message that indicates the reason for failure. This event will be triggered after each observed delay in the input field.

Note: Actual value will not be available for credit card fields.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "validation_failed".
fieldvarchar(100)The field filled by the client.
valuevarchar?The value that was entered by the client.
messagevarchar(100)The result of the validation operation.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "validation_failed",
    "field": "amount",
    "value": "0",
    "message": "Minimum value is 1.",
    "cid": "2083",
    "order_id": "order_68877"
}

cashier_submit

This event will be sent when the client enters all the required data and clicks on the Deposit/Withdrawal button in Cashier. The event context will contain the selected payment method, amount and currency.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "cashier_submit".
payment_methodvarchar(50)Selected payment method.
currencyvarchar(10)Selected currency.
amountdecimalAttempted amount.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "cashier_submit",
    "payment_method": "Credit Card",
    "currency": "USD",
    "amount": 200,
    "cid": "2083",
    "order_id": "order_68877"
}

transaction_attempted

This event will be triggered when our system is ready to send the payment details to the PSP right after a successful submit by the customer. The event context will contain the transaction attempt details.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "transaction_attempted".
transaction<Object>Transaction object with attempted details (see Schema below).
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "transaction_attempted",
    "transaction": {
        "amount": "20",
        "card_number": "454101******6764",
        "charge_amount": 20,
        "charge_currency": "USD",
        "currency": "USD",
        "payment_method": "Credit Card",
        "payment_processor": "Test Card Processor",
        "trace_id": 1070412852
    },
    "cid": "2083",
    "order_id": "order_68877"
}

transaction(success)

This event will be sent when the transaction will be created. The event context will contain the transaction attempt details, including payment method, amount, currency and results of the transaction.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "transaction".
amountdecimalAttempted amount.
card_numbervarchar(20)?Masked card number (only for CC transactions).
charge_amountdecimalTransaction amount selected for processing.
charge_currencyvarchar(10)Transaction currency selected for processing.
currencyvarchar(10)Attempted currency.
error_messagevarchar(255)PSP error message (if one exists).
messagevarchar(255)Message to be displayed for the client.
payment_methodvarchar(50)Selected payment method.
payment_processorvarchar(50)Payment processor.
statusvarchar(16)Transaction status.
trace_idint(11)Transaction identifier.
transaction_idstring(255)Transaction identifier from PSP.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "transaction",
    "amount": "10",
    "card_number": "411111******1111",
    "charge_amount": 10,
    "charge_currency": "USD",
    "currency": "USD",
    "error_message": null,
    "message": "Transaction approved",
    "payment_method": "Credit Card",
    "payment_processor": "Test Card Processor",
    "status": "approved",
    "trace_id": 17780,
    "transaction_id": "345518",
    "cid": "1046",
    "order_id": "order_20717"
}

transaction_failed

This event will be sent when a transaction failure occurs. The event context will contain a description of the issue (invalid token, session expired, etc).

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "transaction_failed".
cidvarchar(50)Unique customer identifier in your system.
amountdecimal?Predefined amount in Cashier.
currencyvarchar(10)?Transaction currency.
messagevarchar(100)Results of the operation.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "transcation_failed",
    "amount": 200,
    "currency": "USD",
    "message": "Token is invalid",
    "cid": "2083",
    "order_id": "order_68877"
}

redirection

This event will be sent when the client will be redirected to the 3DS/APM page. The event context will contain the transaction attempt details and the redirection details (URL) on 3DS/APM page.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "redirection".
payment_methodvarchar(50)Selected payment method.
currencyvarchar(10)Selected currency.
amountdecimalAttempted amount.
transaction_statusvarchar(16)Transaction status.
tidint(11)Transaction identifier.
redirect_urlvarcharURL for the client redirection on 3DS/APM page.
messagevarchar(255)Message to be displayed for the client.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "redirection",
    "payment_method": "Credit Card",
    "amount": 100,
    "currency": "USD",
    "transaction_status": "pending_async",
    "tid": 1070407751,
    "redirect_url": "[https://gw.praxisgate.com/site/process/T005anFWVmNaSVJtK1pUZG5OTFlYZz09](https://gw.praxisgate.com/site/process/T005anFWVmNaSVJtK1pUZG5OTFlYZz09)",
    "message": "[TEST] Transaction status: pending_async. Reason: 3DS authentication required",
    "cid": "2083",
    "order_id": "order_68877"
}

hosted_payment_fields_loaded

This event will be sent when the Credit Card method is selected, and the Hosted Payment Fields form is rendered.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "hosted_payment_fields_loaded".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "hosted_payment_fields_loaded",
    "cid": "2083",
    "order_id": "order_68877"
}

hpf_form_valid

This event will be triggered when all required fields in the HPF form have been completed with valid values.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "hpf_form_valid".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "hpf_form_valid",
    "cid": "2083",
    "order_id": "order_68877"
}

hpf_form_invalid

This event will be triggered when all required fields in the HPF form have been filled in, but at least one of them contains an invalid value.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "hpf_form_invalid".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "hpf_form_invalid",
    "cid": "2083",
    "order_id": "order_68877"
}

apm_fields_loaded

This event will be sent when the apm method is selected, and the APM Fields form is rendered.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "apm_fields_loaded".
fieldsarrayList with the name of the fields.
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "apm_fields_loaded",
    "fields": ["country","email"],
    "cid": "2083",
    "order_id": "order_68877"
}

apm_form_valid

This event will be triggered when all required fields in the APM form have been completed with valid values.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "apm_form_valid".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "apm_form_valid",
    "cid": "2083",
    "order_id": "order_68877"
}

apm_form_invalid

This event will be triggered when all required fields in the HPF form have been filled in, but at least one of them contains an invalid value.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "apm_form_invalid".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "apm_form_invalid",
    "cid": "2083",
    "order_id": "order_68877"
}

thank_you_page_loaded

This event will be triggered when Thank you page is loaded.

VariableTypeStatusDescription
event_typevarchar(100)Type of the triggered event. Always set to "thank_you_page_loaded".
cidvarchar(50)Unique customer identifier in your system.
order_idvarchar(50)Transaction identifier in your system.
{
    "event_type": "thank_you_page_loaded",
    "cid": "2083",
    "order_id": "order_68877"
}