# Sipariş iadesi oluşturma

> suggestedRefund ile iade tutarını hesaplayın, ardından refundCreate ve bir idempotency key ile ürünleri iade edin, stoğa alın ve ödemeyi geri gönderin.

Sayfa: https://lintelagency.com/tr/kaynaklar/graphql/siparis-iadesi-olusturma

## Kısaca

Bir siparişi iade etmek için önce order.suggestedRefund ile tutarı ve iadenin yapılacağı işlemi (transaction) öğrenin, ardından refundCreate’i refundLineItems (restockType ve lokasyonla) ve transactions (parentId, gateway, kind REFUND, amount) ile çağırın. 2026-04 API sürümünden itibaren refundCreate bir @idempotent anahtarı ister; böylece tekrar denenen bir istek iki kez iade yapamaz.

## Bilgiler

- **API:** Admin GraphQL API
- **İşlemler:** order.suggestedRefund, refundCreate
- **Erişim yetkisi:** write_orders
- **Yerini aldığı REST çağrısı:** POST /admin/api/orders/{id}/refunds/calculate.json ve POST /admin/api/orders/{id}/refunds.json
- **API sürümü:** 2026-10
- **Son kontrol:** 2 Kasım 2026

## Nasıl kullanılır

1. CalculateRefund’u iade edilecek satırlar ve adetlerle gönderin. Kargo ücretini dışarıda bırakın ya da onu da iade etmek için refundShipping’i açın.
2. Önerilen işlemin gateway, tutar ve parent transaction ID’sini kind REFUND ile iade girdisine kopyalayın.
3. Ürünleri stoğa geri almak için restockType RETURN (locationId ile), almamak için NO_RESTOCK seçin.
4. RefundItem’ı yeni bir idempotency key ile gönderin. Zaman aşımından sonra tekrar denerken aynı anahtarı kullanın.

## Kod

### suggested-refund.graphql

```graphql
query CalculateRefund($orderId: ID!, $refundLineItems: [RefundLineItemInput!]) {
  order(id: $orderId) {
    id
    suggestedRefund(refundLineItems: $refundLineItems, refundShipping: false) {
      amountSet {
        shopMoney {
          amount
          currencyCode
        }
      }
      suggestedTransactions {
        gateway
        kind
        amountSet {
          shopMoney {
            amount
          }
        }
        parentTransaction {
          id
        }
      }
    }
  }
}
```

### suggested-refund.variables.json

```json
{
  "orderId": "gid://shopify/Order/1234567890",
  "refundLineItems": [
    {"lineItemId": "gid://shopify/LineItem/1111111111", "quantity": 1}
  ]
}
```

### suggested-refund.response.json

```json
{
  "data": {
    "order": {
      "id": "gid://shopify/Order/1234567890",
      "suggestedRefund": {
        "amountSet": {
          "shopMoney": {
            "amount": "49.00",
            "currencyCode": "EUR"
          }
        },
        "suggestedTransactions": [
          {
            "gateway": "shopify_payments",
            "kind": "SUGGESTED_REFUND",
            "amountSet": {"shopMoney": {"amount": "49.00"}},
            "parentTransaction": {"id": "gid://shopify/OrderTransaction/2222222222"}
          }
        ]
      }
    }
  }
}
```

### refund-create.graphql

```graphql
mutation RefundItem($input: RefundInput!, $idempotencyKey: String!) {
  refundCreate(input: $input) @idempotent(key: $idempotencyKey) {
    refund {
      id
      totalRefundedSet {
        shopMoney {
          amount
          currencyCode
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

### refund-create.variables.json

```json
{
  "idempotencyKey": "3b8f6c1d-9a2e-4c7b-8d5f-1e2a3b4c5d6e",
  "input": {
    "orderId": "gid://shopify/Order/1234567890",
    "note": "Returned: size too small",
    "notify": true,
    "refundLineItems": [
      {
        "lineItemId": "gid://shopify/LineItem/1111111111",
        "quantity": 1,
        "restockType": "RETURN",
        "locationId": "gid://shopify/Location/1234567890"
      }
    ],
    "transactions": [
      {
        "orderId": "gid://shopify/Order/1234567890",
        "parentId": "gid://shopify/OrderTransaction/2222222222",
        "gateway": "shopify_payments",
        "kind": "REFUND",
        "amount": "49.00"
      }
    ]
  }
}
```

### refund-create.response.json

```json
{
  "data": {
    "refundCreate": {
      "refund": {
        "id": "gid://shopify/Refund/1234567890",
        "totalRefundedSet": {
          "shopMoney": {
            "amount": "49.00",
            "currencyCode": "EUR"
          }
        }
      },
      "userErrors": []
    }
  }
}
```

## Sınırlar ve özel durumlar

- Boş bir transactions listesi, para iadesi yapmadan iade edilen ürünleri kaydeder ve stoğa alır.
- Varsayılanı false olan allowOverRefunding, toplam iadenin ödenen tutarı aşıp aşamayacağını belirler.
- returnRefund, returns API ile oluşturulmuş bir iadenin parasal kısmını yönetir; refundCreate ise satır bazında stoğa alma ayarı da sunar.
- 60 günden eski siparişler için ayrıca read_all_orders gerekir.

## Sorular

### GraphQL ile bir Shopify siparişi nasıl iade edilir?

refundCreate’i sipariş ID’si, iade edilecek satırlar ve orijinal ödemeye karşı bir REFUND işlemiyle, @idempotent anahtarıyla birlikte çağırın.

### İade tutarını önceden nasıl hesaplarım?

Aynı satırlarla order.suggestedRefund’u sorgulayın. Tutarı, vergileri ve kullanılacak önerilen işlemleri döndürür.

### Stoğa almadan iade yapabilir miyim?

Evet. Her iade satırında restockType’ı NO_RESTOCK yapın.

## Shopify belgeleri

- [refundCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/refundCreate)
- [Order.suggestedRefund](https://shopify.dev/docs/api/admin-graphql/latest/objects/Order)
- [Idempotent requests](https://shopify.dev/docs/api/usage/idempotent-requests)

## İlgili içerikler

- [Verilmiş bir siparişi düzenleme](https://lintelagency.com/tr/kaynaklar/graphql/siparis-duzenleme)
- [Takip numarasıyla gönderim (fulfillment) oluşturma](https://lintelagency.com/tr/kaynaklar/graphql/takip-numarali-gonderim-olusturma)

Lisans: MIT. Kendi mağazanızda da müşteri işlerinizde de ücretsiz kullanabilirsiniz.
