My Profile_


Handling Callbacks

Callbacks are the means by which Moneris Checkout communicates with your merchant checkout page. All callbacks include a single parameter defined as a JSON-formatted string.

In order to handle callbacks, you need to create JavaScript functions that receive the callbacks being sent by Moneris Checkout when the events occur. These functions are linked to the callbacks you set earlier when you prepared your site's checkout page, as described in the Client-Side Checkout Page section.

Callback Types

These callbacks are required to be included in the JavaScript of your page:

Callback Response Fields

Variable Name Type and Limits Description
handler
handler
String
Alphanumeric
Describes the type of callback being used
Possible values:
cancel_transaction
error_event
page_loaded
payment_complete
payment_receipt
ticket
ticket
String
Alphanumeric
Identifies the specific Moneris Checkout instance
This is also returned in the response to the original Preload
response code
response_code
String
Alphanumeric
Identifies the result of the callback. Possible response codes are shown in the Callback Response Codes table.

Page Loaded

Callback Use

To get the page loaded status of the Moneris Checkout page.

This callback is called once the Moneris Checkout is loaded.

JavaScript Set Method for Callback

myCheckout.setCallback("page_loaded",myPageLoad);

JSON Response Message Format


{
    "handler":"page_loaded",
    "ticket":"1539961059DdrvGG3Yj7rxvMAgvRlc4nqKXF7YjT",
    "response_code":"001"
}
            


Cancel Transaction

Callback Use

This callback is called in the event the cardholder presses the cancel button in Moneris Checkout.

Standard is to call the closeCheckout() method to close the Moneris Checkout <div>.

The closeCheckout() method will need to be called and a new Preload request will be required in order to initiate a new Moneris Checkout instance.

JavaScript Set Method for Callback

myCheckout.setCallback("cancel_transaction",myCancelTransaction);

JSON Response Message Format


{
    "handler":"cancel_transaction",
    "ticket":"1539961059DdrvGG3Yj7rxvMAgvRlc4nqKXF7YjT",
    "response_code":"001"
}
            


Error Event

Callback Use

When an error occurs during the checkout process. This requires the Moneris Checkout session to be closed using the closeCheckout() function

To attempt the transaction again, a new Preload request must be sent to the Moneris Checkout server in order to get a new transaction ticket number.

JavaScript Set Method for Callback

myCheckout.setCallback("error_event",myErrorEvent);

JSON Response Message Format


{
    "handler":"error_event",
    "ticket":"1539961059DdrvGG3Yj7rxvMAgvRlc4nqKXF7YjT",
    "response_code":"902"
}
            


Payment Receipt

Callback Use

Transaction is complete and receipt is ready to be collected.

If you have chosen to have Moneris Checkout generate the receipt, this callback is called once the Moneris Checkout displays the transaction receipt.

JavaScript Set Method for Callback

myCheckout.setCallback("payment_receipt",myPaymentReceipt);

JSON Response Message Format


{
    "handler": "payment_receipt",
    "ticket": "1539961059DdrvGG3Yj7rxvMAgvRlc4nqKXF7YjT",
    "response_code": "001"
}
            


Payment Complete

Callback Use

This callback is called once Moneris Checkout has completed payment.

Moneris Checkout should be closed by calling the closeCheckout() method

JavaScript Set Method for Callback

myCheckout.setCallback("payment_complete",myPaymentComplete);

JSON Response Message Format


{  
    "handler":"payment_complete",
    "ticket":"1539961059DdrvGG3Yj7rxvMAgvRlc4nqKXF7YjT",
    "response_code":"001"
}
            


Callback Response Codes

Response Code Reason
001 Success
902 3-D Secure failed on response
2001 Invalid ticket/ticket re-use