/v2/orders/{order_id}/refund
Request for refund.
Available only for payments in CAPTURED
or PARTIALLY_REFUNDED
status.
On success, the payment status changes as follows:
- to
REFUNDED
if the full amount was refunded - or
PARTIALLY_REFUNDED
if the cart has some items left after the refund.
The method is asynchronous.
You can find out the refund result by using the event mechanism
or calling the operation status method.
The OPERATION_STATUS_UPDATED
event is sent both if the refund succeeds
and fails.
If a full refund is required, just pass refundAmount
set to the order amount.
For a partial refund, you should additionally pass the final cart of the provided products and services in the request. The final cart is created from the current cart by excluding some items or by revising the quantity/costs of the items that were refunded.
Note
Please note that you should specify the cart status after the refund rather than the list of products or services to be refunded.
The targetCart
field describes the final cart status after the refund.
If the field is not specified, it's considered that the cart is refunded in full.
The targetShipping
field is only applicable to Yandex Pay Checkout. In other cases, leave the field
blank.
The field describes the final delivery status after the refund.
If the field is not specified or is null
, it's considered that the delivery cost is refunded in full.
Примеры вызовов
Let's take an example of an order with the orderId = Order-123
and the following cart:
{
"items": [
{
"productId": "id-1",
"price": "50",
"title": "Ballpoint pen",
"quantity": {
"count": "10"
},
},
{
"productId": "id-2",
"price": "200",
"title": "Notepad",
"quantity": {
"count": "2"
},
}
]
}
Пример полного возврата
http POST https://sandbox.pay.yandex.ru/api/merchant/v2/orders/Order-123/refund \
"Authorization: Api-Key ${API_KEY}" 'refundAmount:="900.00"'
Примеры частичного возврата
Возврат единиц товара
Suppose that two ballpoint pens need to be refunded. This is done using the following request
http POST https://sandbox.pay.yandex.ru/api/merchant/v2/orders/Order-123/refund \
"Authorization: Api-Key ${API_KEY}" \
'targetCart[items][0]:={"productId": "id-1", "quantityCount": "8"}' \
'targetCart[items][1]:={"productId": "id-2", "quantityCount": "2"}' \
'refundAmount:="100.00"'
In this example:
- The quantity of ballpoint pens is decreased by 2, from 10 to 8 units.
- The
price
field is skipped in the request, but it's quite acceptable to specify it. quantityCount
of the notepad item remains unchanged, it could have been omitted.
Возврат части денег
Let's say a refund of RUB 30 is requested for each notepad. This is achieved by reducing the item price.
http POST https://sandbox.pay.yandex.ru/api/merchant/v2/orders/Order-123/refund \
"Authorization: Api-Key ${API_KEY}" \
'targetCart[items]:=[{"productId": "id-1"}, {"productId": "id-2", "price": "170"}]' \
'refundAmount:="60.00"'
In this example:
- The notepad price is decreased by 30, from RUB 200 to RUB 170.
- That is, a refund of RUB 60 is made, since there're two notepads.
- The
quantityCount
fields are missing, but it's quite acceptable to specify their previous values.
Request
POST
https://pay.yandex.ru/api/merchant/v2/orders/{order_id}/refund
Production
POST
https://sandbox.pay.yandex.ru/api/merchant/v2/orders/{order_id}/refund
Sandbox
Path parameters
Name |
Description |
order_id* |
Type: string Order ID on the merchant's side that was passed in response to /order/create. Max length: |
Body
application/json
{
"branchId": "string",
"externalOperationId": "string",
"managerId": "string",
"motive": "string",
"refundAmount": "123.45",
"targetCart": {
"items": [
{
"price": "123.45",
"productId": "string",
"quantityCount": "123.45"
}
]
},
"targetShipping": {
"amount": "123.45"
}
}
Name |
Description |
refundAmount* |
Type: string<double> Amount to be refunded. Example: |
branchId |
Type: string ID of the point of sale Max length: |
externalOperationId |
Type: string Refund operation ID in the merchant system. The ID must be unique. Pass this parameter to be able to track the refund operation status via the operations/{external_operation_id} method. If the operation is not completed (is either in progress or stopped), calling the method again with the same arguments and the same If the refund process is launched successfully, calling the refund method with the same Max length: |
managerId |
Type: string Manager ID Max length: |
motive |
Type: string Refund reason Max length: |
targetCart |
Type: TargetCart Describes the final cart status after the refund. If the field is not specified, it's considered that the cart is refunded in full. |
targetShipping |
Type: TargetShipping Applicable to Yandex Pay Checkout only. In other cases, leave the field blank. Describes the final delivery status after the refund.
If the field is not specified or is |
TargetCart
Name |
Description |
items |
Type: TargetCartItem[] |
TargetShipping
Name |
Description |
amount |
Type: string<double> Cost of delivery after the operation is completed Example: |
TargetCartItem
Name |
Description |
productId* |
Type: string Cart item ID as of order creation. If you pass an ID that was not present in the initial cart, an error occurs. Max length: |
price |
Type: string<double> Price per product/service unit after the operation is completed. Specify if the unit price gets lower as a result of the operation. This may be helpful if part of the money paid for the product needs to be refunded or when confirming the order. If the field is not specified in the request, the price is considered unchanged. Example: |
quantityCount |
Type: string<double> The number of product/service units the user gets after the operation is completed. If the field is not specified in the request, the number is considered unchanged. Example: |
Responses
200 OK
Body
application/json
{
"code": 200,
"data": {
"operation": {
"amount": "123.45",
"created": "2022-12-29T18:02:01Z",
"externalOperationId": "string",
"operationId": "c3073b9d-edd0-49f2-a28d-b7ded8ff9a8b",
"operationType": "AUTHORIZE",
"orderId": "string",
"params": {},
"pointsAmount": "123.45",
"reason": "string",
"status": "PENDING",
"updated": "2022-12-29T18:02:01Z"
}
},
"status": "success"
}
Name |
Description |
code |
Type: number Default: |
data |
Type: OperationResponseData |
status |
Type: string Default: Enum: |
OperationResponseData
Name |
Description |
operation |
Type: Operation |
Operation
Name |
Description |
amount* |
Type: string<double> Transaction amount in a fiat currency Example: |
operationId* |
Type: string<uuid> Max length: |
operationType* |
Type: string Enum: |
orderId* |
Type: string Max length: |
created |
Type: string<date-time> Date and time when the operation was created (ISO 8601) |
externalOperationId |
Type: string Operation ID on the merchant side Max length: |
params |
Type: object |
pointsAmount |
Type: string<double> Transaction amount in Plus points Example: |
reason |
Type: string Error cause Max length: |
status |
Type: string Default: Enum: |
updated |
Type: string<date-time> Date and time when the operation was updated (ISO 8601) |
No longer supported, please use an alternative and newer version.