Mangopay / mangopay

MANGOPAY API Known Issues
3 stars 2 forks source link

Allow same-amount partial refunds through use of idempotencyKey #60

Open tasosz opened 4 years ago

tasosz commented 4 years ago

Hi,

I need to be able to initiate multiple partial refunds for same amounts (within minutes/hours of each other), but currently this is prevented. From the API docs:

If you're doing a partial Refund, note that you can only refund the same amount on the same transaction once per day (this is to prevent unintended duplicate refunds). After 24h you can do another refund of the same amount on the same transaction. If it is a different amount on the same transaction, there is not this limit. This is a good measure to prevent unintended duplicate refunds.

Here is my example and need: A buyer has a payment with 5 same items (5xEUR10.00) and initiates a refund of one of them (partial refund - EUR5.00). A few minutes later decides to also return the second one and initiates a second refund (partial refund - EUR5.00).

In this scenario, I can verify I am getting the documented result: "ResultCode":"005407","ResultMessage":"Duplicated operation: you cannot reimburse the same amount more than once for a transaction during the same day."

However, this is a genuine Business need rather than an accidental refund. And I have no reliable way to work around this limitation.

I am proposing that I should not be getting a failure when I am using a unique IdempotencyKey for same-amount partial refunds. I.e. maintain the current "unintended duplicate refunds" protection, but also allow a client system to specify the uniqueness of a partial refund through the use of an IdempotencyKey. Also, through the use of the IdempotencyKey, the same 24h semantics are maintained:

If you use the same Idempotency Key within 24 hours, we’ll block all but the first one (ie you can rerun your same requests knowing that we’ll only ever treat them once in 24 hours) – this is particularly useful for direct payments.

. . . Related ticket: ref:_00D24JOOb._5001o4QUCmg:ref