question

Dyego Costa avatar image
Dyego Costa asked hammer answered

CloverError deprecated?

Previously I used to rely on CloverError to identify the errors that came back from the device.

Example: Start a sale and hit the "back" (cancel) button on the Clover device.

Right now to handle a failed sale response I use the ICloverConnectorListener#onSaleResponse(response) which is called with a remotepay.SaleResponse. On that callback I can only identify the error with the response.reason which is "CANCEL". Previously I'd map that to CloverError.CANCELED but that is not valid anymore ("CANCEL" !== 'canceled'), is there anything like the CloverError I can use now to map the error to a presentable message to the user?

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

hammer avatar image
hammer answered

For responses in general (this includes the SaleResponse), the general contract of return values is:

  1. Response
    • success: {true | false} - true indicates success
    • result: {ResponseCode} - see https://github.com/clover/remote-pay-cloud-api/blob/master/remotepay/ResponseCode.js
    • reason: {string message | null}
    • message: {string detailed message | null}

Note that response code enumerates:

ResponseCode = {
  SUCCESS : "SUCCESS",
  FAIL : "FAIL",
  UNSUPPORTED : "UNSUPPORTED",
  CANCEL : "CANCEL",
  DUPLICATE : "DUPLICATE",
  ERROR : "ERROR"
};
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community