# Refunds

## Refund card or open banking payments

> Return the funds to the customer's bank.If refunding a payment that is not yet captured it will be cancelled

```json
{"openapi":"3.1.0","info":{"title":"E-commerce Gateway API","version":"1.0.0"},"servers":[{"url":"https://sandbox-api.ecomm.api.tietoevry.com"}],"security":[{"OAuth2ClientAuthentication":[]}],"components":{"securitySchemes":{"OAuth2ClientAuthentication":{"type":"openIdConnect","description":"This API uses OAuth 2 with the client credentials flow. [More info](https://www.rfc-editor.org/rfc/rfc6749#section-4.4)","openIdConnectUrl":"https://ecomm.api.tietoevry.com/auth/realms/participants-tietoevry/protocol/openid-connect/token"}},"schemas":{"RefundPaymentRequest":{"type":"object","description":"The request for refunding a payment","properties":{"instructedAmount":{"$ref":"#/components/schemas/Amount","description":"Amount to be refunded"},"paymentId":{"type":"string","description":"Unique ID of the payment","maxLength":64}},"required":["instructedAmount","paymentId"],"title":"Refund Payment Request"},"Amount":{"type":"object","properties":{"amount":{"type":"string","description":"The amount given with fractional digits, where fractions must be compliant to the currency definition.\nUp to 14 significant figures. The decimal separator is a dot.\nCan be 0 for account verification (save payment method for future usage without initial payment).\n\n**Example:**\nValid representations for EUR with up to two decimals are:\n  * 1056\n  * 5768.2\n  * 1.50\n  * 5877.78\n"},"currency":{"type":"object","description":"ISO 4217 alpha-3 currency code","properties":{"currencyCode":{"type":"string"},"defaultFractionDigits":{"type":"integer","format":"int32"},"displayName":{"type":"string"},"numericCode":{"type":"integer","format":"int32"},"numericCodeAsString":{"type":"string"},"symbol":{"type":"string"}}}},"required":["amount","currency"]},"RefundPaymentResponse":{"type":"object","description":"The response after refunding a card payment","properties":{"instructedAmount":{"$ref":"#/components/schemas/Amount","description":"Refunded amount"},"paymentId":{"type":"string","description":"Unique ID of the refunded payment","maxLength":64},"refundId":{"type":"string","description":"Unique ID of the refund","maxLength":64},"refundStatus":{"type":"string","description":"Current status of the refund","enum":["INITIALIZED","COMPLETED","FAILED","REVERTED"]}},"title":"Refund Payment Response"},"ErrorResponse":{"type":"object","properties":{"apiClientMessages":{"type":"array","items":{"$ref":"#/components/schemas/ApiClientMessage"}}}},"ApiClientMessage":{"type":"object","properties":{"category":{"type":"string","enum":["ERROR"]},"code":{"type":"string"},"text":{"type":"string"}}}}},"paths":{"/egw/{version}/refunds":{"post":{"description":"Return the funds to the customer's bank.If refunding a payment that is not yet captured it will be cancelled","operationId":"refundPayment","parameters":[{"description":"ID of the request, unique to the call, as determined by the initiating party","in":"header","name":"X-Request-Id","required":true,"schema":{"type":"string","format":"uuid","description":"ID of the request, unique to the call, as determined by the initiating party"}},{"in":"path","name":"version","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundPaymentRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundPaymentResponse"}}},"description":"OK"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Bad Request"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Not Found"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Conflict"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Service Unavailable"}},"summary":"Refund card or open banking payments","tags":["Refund API"]}}}}
```

## Revert refund for open banking payments

> If the refund turns out to be unsuccessful it can be revertedto align the payment status and amount with the real state

```json
{"openapi":"3.1.0","info":{"title":"E-commerce Gateway API","version":"1.0.0"},"servers":[{"url":"https://sandbox-api.ecomm.api.tietoevry.com"}],"security":[{"OAuth2ClientAuthentication":[]}],"components":{"securitySchemes":{"OAuth2ClientAuthentication":{"type":"openIdConnect","description":"This API uses OAuth 2 with the client credentials flow. [More info](https://www.rfc-editor.org/rfc/rfc6749#section-4.4)","openIdConnectUrl":"https://ecomm.api.tietoevry.com/auth/realms/participants-tietoevry/protocol/openid-connect/token"}},"schemas":{"RefundReversalResponse":{"type":"object","description":"The response after reversing a refund","properties":{"instructedAmount":{"$ref":"#/components/schemas/Amount","description":"Refunded amount"},"paymentId":{"type":"string","description":"Unique ID of the refunded payment","maxLength":64},"refundId":{"type":"string","description":"Unique ID of the refund","maxLength":64},"refundStatus":{"type":"string","description":"Current status of the refund","enum":["INITIALIZED","COMPLETED","FAILED","REVERTED"]}},"title":"Refund Reversal Response"},"Amount":{"type":"object","properties":{"amount":{"type":"string","description":"The amount given with fractional digits, where fractions must be compliant to the currency definition.\nUp to 14 significant figures. The decimal separator is a dot.\nCan be 0 for account verification (save payment method for future usage without initial payment).\n\n**Example:**\nValid representations for EUR with up to two decimals are:\n  * 1056\n  * 5768.2\n  * 1.50\n  * 5877.78\n"},"currency":{"type":"object","description":"ISO 4217 alpha-3 currency code","properties":{"currencyCode":{"type":"string"},"defaultFractionDigits":{"type":"integer","format":"int32"},"displayName":{"type":"string"},"numericCode":{"type":"integer","format":"int32"},"numericCodeAsString":{"type":"string"},"symbol":{"type":"string"}}}},"required":["amount","currency"]},"ErrorResponse":{"type":"object","properties":{"apiClientMessages":{"type":"array","items":{"$ref":"#/components/schemas/ApiClientMessage"}}}},"ApiClientMessage":{"type":"object","properties":{"category":{"type":"string","enum":["ERROR"]},"code":{"type":"string"},"text":{"type":"string"}}}}},"paths":{"/egw/{version}/refunds/{refundId}/revert":{"patch":{"description":"If the refund turns out to be unsuccessful it can be revertedto align the payment status and amount with the real state","operationId":"revertRefund","parameters":[{"description":"ID of the request, unique to the call, as determined by the initiating party","in":"header","name":"X-Request-Id","required":true,"schema":{"type":"string","format":"uuid","description":"ID of the request, unique to the call, as determined by the initiating party"}},{"description":"Unique ID of the refund","in":"path","name":"refundId","required":true,"schema":{"type":"string","description":"Unique ID of the refund","maxLength":64}},{"in":"path","name":"version","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundReversalResponse"}}},"description":"OK"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Bad Request"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Not Found"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Conflict"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Service Unavailable"}},"summary":"Revert refund for open banking payments","tags":["Refund API"]}}}}
```
