Adding Moneris Checkout to Zen Cart

July 2023

Adding Moneris Checkout to Zen Cart

A client with an existing ecommerce site was notified by Moneris that the old Hosted Payment Page was retiring and they needed to update to the new Moneris Checkout. My first step was to look for existing solutions. Unfortunately the Zen Cart community hasn't released a new Moneris plugin and the Moneris Zen Cart documentation is non existent.

Thankfully, between the code for the old Zen Cart Moneris Hosted Pay Page plugin and the Moneris Checkout integration guide, I was able to work out a solution.

First I copied the old /includes/modules/payment/monerishpp.php to create the new Moneris Checkout plugin and any associated language files. It was a fast and easy way to set up the new payment plugin for Zen Cart. Going through all the Moneris Checkout documentation told me it was 3 step process.

  1. In my new moneris_checkout.php module  function process_button() all the order and customer data is sent to the Moneris Checkout Gateway server as a preload request. The response includes a ticket number which uniquely identifies the instance and must be passed to the next step in the checkout process.
  2. The page that calls myCheckout.startCheckout( ticket # ); and displays the payment fields. Also needs a bunch of callback functions to close the checkout and redirect the user. I was caught up on this for a while because when the callback is successful I originally thought it meant the payment was successful (credit card is good, expiry is good, etc). But a success status in the callback is just success that Moneris received the data. There's still a final step.
  3. When payment is complete a final receipt request is sent to Moneris Checkout sending the ticket #. This response includes a code.

    If there was an error with the payment information a message can be added to the message stack and the user is taken back to the payment page.

    If the receipt response code is < 50 then the Moneris payment was approved.