Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mortenbekditlevsen opened this issue May 3, 2024 · 1 comment
Open

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

mortenbekditlevsen opened this issue May 3, 2024 · 1 comment

Comments

@mortenbekditlevsen
Copy link

mortenbekditlevsen commented May 3, 2024

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.

  • Operating Version:
    iOS 17

  • SDK version:
    4.0.1

Failure Logs

Please include any relevant log snippets or files here.

@nataliq-pp
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants