iZettle / sdk-ios

Add card payments from Zettle to your own app
https://developer.zettle.com/docs/ios-sdk
Other
81 stars 37 forks source link

Request to expand / align refund error codes in SDK #457

Open mortenbekditlevsen opened 4 months ago

mortenbekditlevsen commented 4 months ago

Expected Behavior

I expect to be able to distinguish different error codes in my code base, so that I can communicate correctly with the end user.

This issue is related to previously closed issue: #249

Please describe the behavior you are expecting.

Current Behavior

I am trying to make sense of the various refund errors that can occur through the API.

Currently it appears that the refund errors are not covered by the error codes defined in the SDK - and furthermore we get different error codes for apparently similar error situations based on wether we are in developer mode or on a demo account.

Here are some errors that we experience when using a demo account:

Error Domain=com.izettle.payments-sdk-ios.refund.error Code=2 "#AlreadyRefunded" UserInfo={izTitle=An error has occurred, NSLocalizedDescription=#AlreadyRefunded, izMessage=#AlreadyRefunded}

Error Domain=com.izettle.payments-sdk-ios.refund.error Code=2 "#RefundInsufficientFunds" UserInfo={izTitle=An error has occurred, NSLocalizedDescription=#RefundInsufficientFunds, izMessage=#RefundInsufficientFunds}

Error Domain=com.izettle.payments-sdk-ios.refund.error Code=2 "#RefundAmountExceedOriginalAmount" UserInfo={izTitle=An error has occurred, NSLocalizedDescription=#RefundAmountExceedOriginalAmount, izMessage=#RefundAmountExceedOriginalAmount}

And some errors from when we are in developer mode:

Error Domain=com.izettle.sdk.error Code=-100 "An error has occurred / Payment not found" UserInfo={izTitle=An error has occurred, NSLocalizedDescription=An error has occurred / Payment not found, izMessage=Payment not found}

Error Domain=com.izettle.payments-sdk-ios.refund.error Code=1 "An error has occurred / Refund not approved by acquirer." UserInfo={izTitle=An error has occurred, NSLocalizedDescription=An error has occurred / Refund not approved by acquirer., izMessage=Refund not approved by acquirer.}

Error Domain=com.izettle.payments-sdk-ios.refund.error Code=2 "An error has occurred / Refund amount exceeds original amount." UserInfo={izTitle=An error has occurred, NSLocalizedDescription=An error has occurred / Refund amount exceeds original amount., izMessage=Refund amount exceeds original amount.}

It appears that in developer mode, the errors that we can provoke do indeed have different error codes. But one of those codes (2) occurs for every error that we have been able to provoke using a demo account.

We do not have access to a production account, so we have no guess as to whether it behaves more like a demo account or developer mode - or in a third fashion.

Can you give any advice for error handling for refunds - and specifically for distinguishing different error scenarios?

Steps to Reproduce

Perform refunds in developer mode and on a demo account and observe the details of the NSErrors that are thrown.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

Please include any relevant log snippets or files here.

nataliq-pp commented 4 months ago

Hi @mortenbekditlevsen, the errors that you experience during developer mode cover all refund error codes but perhaps the confusing part is that the error with code 2 can have multiple reasons and we're simulating only one of them.

We understand that there might be cases in which knowing the exact reason for a refund failure could be useful. Thank you for highlighting this gap in our documentation. We will consider this request during our future plannings.

Meanwhile, we want to unblock you as much as possible. Please find below a list of the most common technical errors (code 2) and their description: NSLocalizedDescription Description
#AlreadyRefunded Payment was already refunded
#RefundInsufficientFunds Account does not have sufficient funds to perform refund
#RefundAmountExceedOriginalAmount Trying to perform refund with amount higher than original payment
#RefundFailedRefundGenericNotSupported Payment is not refundable
#RefundDateExpired Payment refund is too old to be refunded

This list might not be exhaustive; any other message can be considered failure due to unknown reasons. Note that this is not official API and might change without notice but it might be useful until we release a version which defines the refund failure reasons similar to Android. We will post an update here when that is available.

Hope that this is helpful! Do not hesitate to ask us any further questions!