> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dintero.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.dintero.com/feedback

```json
{
  "path": "/docs/order-update-refund",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Update an order with reversed items

> Modify a Dintero order by reversing existing items and adding new ones using the draft order endpoints to keep the captured amount and refunds aligned.

Update an order where existing items are reversed and new items are added.

### Create order

* [POST /v1/accounts/\{aid}/shopping/draft\_orders](/orders-api.html#operation/aid_draft_orders_post)
* [PUT /v1/accounts/\{aid}/shopping/draft\_orders/\{id}/complete](/orders-api.html#operation/aid_draft_orders_id_complete_put)

```
{
    "options": {
        "generate_order_id": "ALPHANUMERIC_9"
    },
    "order": {
        "currency": "NOK",
        "items": [
            {
                "id": "175938",
                "line_id": 1,
                "quantity": 2,
                "gross_amount": 39800,
                "tax_lines": [
                    {
                        "amount": 7960,
                        "percentage": 25
                    }
                ],
                "description": "Stablestol for utendørsbruk",
                "description_alias": "Staplestol"
            }
        ]
    }
}
```

#### Authorize and capture the order

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/authorizations](/orders-api.html#operation/aid_orders_id_authorization_post)
* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/captures](/orders-api.html#operation/aid_orders_id_capture_post)

```
{
    "items": [
        {
            "amount": 39800,
            "line_id": 1
        }
    ],
    "payment_details": {
        "payment_id": "PID_123"
    },
    "success": true
}
```

### Reverse order item and add new item

Update existing order, removing (reversing) existing item and adding a
new item.

* [POST /v1/accounts/\{aid}/shopping/draft\_orders](/orders-api.html#operation/aid_draft_orders_post)
* [PUT /v1/accounts/\{aid}/shopping/draft\_orders/\{id}/complete](/orders-api.html#operation/aid_draft_orders_id_complete_put)

```
{
    "options": {
        "order_id": "{order_id}"
    },
    "order": {
        "currency": "NOK",
        "items": [
            {
                "id": "175938",
                "line_id": 2,
                "quantity": 2,
                "gross_amount": -39800,
                "tax_lines": [
                    {
                        "amount": -7960,
                        "percentage": 25
                    }
                ],
                "description": "Stablestol for utendørsbruk",
                "description_alias": "Staplestol",
                "reversed_reason": "Replace item",
                "related_item": {
                    "line_id": 1,
                    "type": "reversed"
                }
            },
            {
                "id": "003929",
                "line_id": 3,
                "quantity": 1,
                "gross_amount": 39800,
                "tax_lines": [
                    {
                        "amount": 7960,
                        "percentage": 25
                    }
                ],
                "description": "Stablestol for innendørsbruk",
                "description_alias": "Staplestol Lux"
            }
        ]
    }
}
```

> use `related_item` to link the item that is being reversed

#### Authorize and capture reversed item

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/authorizations](/orders-api.html#operation/aid_orders_id_authorization_post)
* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/captures](/orders-api.html#operation/aid_orders_id_capture_post)

```
{
    "items": [
        {
            "amount": -39800,
            "line_id": 2
        }
    ],
    "payment_details": {
        "payment_id": "PID_123"
    },
    "success": true
}
```

#### Authorize and capture the new item

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/authorizations](/orders-api.html#operation/aid_orders_id_authorization_post)
* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/captures](/orders-api.html#operation/aid_orders_id_capture_post)

```
{
    "items": [
        {
            "amount": 39800,
            "line_id": 3
        }
    ],
    "payment_details": {
        "payment_id": "PID_123"
    },
    "success": true
}
```

### Refund remaining

We recommend that an additional item is included in the draft update
if the original authorization is higher than the new items.

#### Authorize and capture the new item + refund line

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/authorizations](/orders-api.html#operation/aid_orders_id_authorization_post)
* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/captures](/orders-api.html#operation/aid_orders_id_capture_post)

```
{
    "items": [
        {
            "amount": 39800,
            "line_id": 3
        },
        {
            "amount": 1000,
            "line_id": 4
        }
    ],
    "payment_details": {
        "payment_id": "PID_123"
    },
    "success": true
}
```

#### Refund remaining authorization

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/refund](/orders-api.html#operation/aid_orders_id_refund_post)

```
{
    "items": [
        {
            "amount": 1000,
            "line_id": 4
        }
    ],
    "payment_details": {
        "payment_id": "PID_123"
    },
    "success": true
}
```

### Part authorization / captures

We recommend that additional authorization/captures are added to the new item
if the original authorization/capture is below the new item amount

* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/authorizations](/orders-api.html#operation/aid_orders_id_authorization_post)
* [POST /v1/accounts/\{aid}/shopping/orders/\{order\_id}/captures](/orders-api.html#operation/aid_orders_id_capture_post)

> Support for multiple authorization (same item) is planned for 2021-06-01

```
{
    "items": [
        {
            "amount": 1000,
            "line_id": 3
        }
    ],
    "payment_details": {
        "payment_id": "PID_321"
    },
    "success": true
}
```
