Przejdź do treści

Callback Refundacji

Sklep może zainicjować zwrot całości lub części płatności otrzymanej za zamówienie. Środki zostaną zwrócone metodą płatności, która została użyta przez klietna do jej dokonania.

Należy pamiętać, że OA przyjmie zlecenie refundacji od merchanta, nawet jeśli wartość zlecanej refundacji jest wyższa niż aktualne saldo merchanta. W tym wypadku, realizacji refundacji będzie oczekiwać na dostępność odpowiedniego salda na rachunku merchanta. Zlecenia refundacji wymagają unikalnego caseId, które musi być unikalne dla zamówienia (różne zamówienia mogą mieć takie samo caseId). Jeśli dane caseId było już użyte dla danego zamówienia, OpenApp odrzuci zlecenie jako już zrealizowane.

sequenceDiagram
  autonumber
  actor User
  participant OpenApp
  participant Merchant
  activate User
  Merchant->>+OpenApp: Refund callback
  OpenApp->>-User: Refund

Request

Żadanie refundacji wykonywane jest przez żądanie POST na następujący endpoint:

POST {{OpenAppUrl}}/merchant/v1/orders/refund

Ciało żądania zawiera informacje o zamówieniu, kwotę i opcjonalnie konkretne produkty, dla których wykonywana jest refundacja:

Refund request
{
  "oaOrderId": "OA12345678901234",
  "shopOrderId": "WS1213ASDZXC231A",
  "currency": "PLN",
  "amount": 1999,
  "reason": "RETURNED",
  "caseId": "RET-123434",
  "notes": "Returned without charger cables.",
  "products": [
    {
      "id": "id123",
      "refundedQuantity": 1,
      "amount": 1999
    }
  ]
}
Refund request
{
    "additionalProperties": false,
    "type": "object",
    "properties": {
        "oaOrderId": {
            "description": "The OpenApp order ID.",
            "type": "string",
            "title": "oaOrderId"
        },
        "shopOrderId": {
            "description": "The unique ID of the order.",
            "maxLength": 36,
            "type": "string",
            "title": "shopOrderId"
        },
        "currency": {
            "type": "string",
            "title": "currency"
        },
        "amount": {
            "description": "The refunded amount. Price is expressed as the number (integer) of 1/100s of the price.",
            "minimum": 0,
            "type": "integer",
            "title": "amount"
        },
        "caseId": {
            "description": "Reference ID of the claim made by the user or the refund ID. Must be unique for the order.",
            "maxLength": 36,
            "type": "string",
            "title": "caseId"
        },
        "reason": {
            "description": "Reason for the refund",
            "enum": [
                "OTHER",
                "RETURNED",
                "WARRANTY"
            ],
            "type": "string",
            "title": "reason"
        },
        "notes": {
            "description": "Optional explanation of the refund",
            "maxLength": 500,
            "type": "string",
            "title": "notes"
        },
        "products": {
            "description": "Optional list of products that were refunded.",
            "type": "array",
            "items": {
                "$ref": "#/definitions/RefundProduct"
            },
            "title": "products"
        }
    },
    "required": [
        "amount",
        "caseId",
        "currency",
        "oaOrderId",
        "reason",
        "shopOrderId"
    ],
    "definitions": {
        "RefundProduct": {
            "title": "RefundProduct",
            "type": "object",
            "properties": {
                "id": {
                    "description": "The unique ID of the product.",
                    "maxLength": 36,
                    "type": "string",
                    "title": "id"
                },
                "refundedQuantity": {
                    "description": "The number of refunded products.",
                    "minimum": 0,
                    "type": "number",
                    "title": "refundedQuantity"
                },
                "amount": {
                    "description": "The refunded amount for this product. Price is expressed as the number (integer) of 1/100s of the price.",
                    "minimum": 0,
                    "type": "integer",
                    "title": "amount"
                },
                "notes": {
                    "description": "Optional explanation of the refund",
                    "maxLength": 500,
                    "type": "string",
                    "title": "notes"
                }
            },
            "required": [
                "amount",
                "id",
                "refundedQuantity"
            ]
        }
    },
    "$schema": "http://json-schema.org/draft-07/schema#"
}

Response

W odpowiedzi, OpenaApp potwierdza przyjęcie zlecenia. Realizacja zwrotu do klienta będzie widoczna w raporcie rozliczeniowym sklepu.

Errors

Error name Code
OrderNotFoundException 404
MerchantOrderOwnershipException 404
RefundExistsException 409
RefundTooMuchException 400
MerchantWalletNotFoundException 404
UserNotFoundException 404