1. Initialize the cardPresentRefund endpoint

Initialize the card present refund endpoint and grab the totalAmount, terminalId, apiToken, storeId and istConfigCode from the request body.

2. Build the cardPresentRefundPayload request object

Build the card present refund request object that you will send to the Moneris cloud. The type of functionality that will be executed by your POST request is dependent on the “action” value that you send in the request. For a full list of all the possible fields for the request, visit the API spec at the Card Present Refund.

3. Send the object and get a response

Send the object you created to the “baseURL” and grab the data from the response.

NOTE: The baseURL for the Production Environment is https://ippos.moneris.com/v3/Terminal/.

4. Handle response

Check the response to determine if the Moneris Go device is available. If the status value in the response is "Pinpad is Currently Performing Another Transaction", the device is unavailable.

Check the response to determine if your request was validated and approved. If “errorDetails” exists within the object then an error has occurred during validation. 

Start polling against the “receiptUrl” which is a field that you will get in your response that is used to get the final refund response. Check the statusCode of the final card present refund response for a value of “5207” which indicates that the card present refund was successful.

A number of additional statusCodes exist that need to be accounted for. For a full list of statusCodes visit Glossary.

Your polling function will look like this and should check the response.data.receipt.data.response[0].completed value for when it has a value of "true" which would indicate that the refund is finished. 


NOTE: Set up a polling frequency interval of 2 seconds or more to ensure the Moneris cloud server recognizes your requests as legitimate and avoids mistaking them for a network attack.

5. Full code example

Below is the full code example using Node and express listening on http://localhost:3000.