---
title: GraphQL post-payment
description: >-
  Manage payment captures, fulfillment tracking, refunds, and order
  cancellations using the GraphQL Admin API.
source_url:
  html: 'https://shopify.dev/docs/api/commerce-components/pay/graphql-post-payment'
  md: 'https://shopify.dev/docs/api/commerce-components/pay/graphql-post-payment.md'
---

# GraphQL post-payment

The post-payment process may involve capturing payments, adding tracking fulfillments, and issuing refunds. This section provides examples of how to use the GraphQL Admin API for these tasks.

***

## Payment capture

Captures payment for an authorized transaction on an order if the **Payments** setting is configured to manual capture. Using the order ID, you can fetch an [`order`](https://shopify.dev/docs/api/admin-graphql/latest/queries/order) and [`OrderTransaction`](https://shopify.dev/docs/api/admin-graphql/latest/objects/OrderTransaction), then call the GraphQL Admin API's [`orderCapture`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderCapture) mutation to capture the authorized payment.

The following example captures an authorized payment using the `orderCapture` mutation:

## orderCapture

```graphql
mutation orderCapture($input: OrderCaptureInput!) {
  orderCapture(input: $input) {
    transaction {
      id
      amountSet {
        shopMoney {
          amount
          currencyCode
        }
        presentmentMoney {
          amount
          currencyCode
        }
      }
      kind
      status
    }
    userErrors {
      field
      message
    }
  }
}
```

## Input

```json
{
  "input": {
    "amount": "10.00",
    "currency": "USD",
    "id": "gid://shopify/Order/1",
    "parentTransactionId": "gid://shopify/OrderTransaction/2"
  }
}
```

## Response

```json
{
  "orderCapture": {
    "transaction": {
      "id": "gid://shopify/OrderTransaction/3",
      "amountSet": {
        "shopMoney": {
          "amount": "10.00",
          "currencyCode": "USD"
        },
        "presentmentMoney": {
          "amount": "10.00",
          "currencyCode": "USD"
        }
      },
      "kind": "CAPTURE",
      "status": "SUCCESS"
    },
    "userErrors": []
  }
}
```

Shop Pay Wallet supports multi-capture, enabling you to execute partial captures by providing any amount less than the currently uncaptured amount.

For the first partial capture made against an authorization, you can also void the remaining authorization after capturing an amount by including `"finalCapture": true` in your partial capture input. For more details, refer to the [`orderCapture` documentation](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderCapture#argument-input).

**Note:**

After an authorization has been partially captured, it can no longer be voided by any means. It must either be captured, or left to expire after the 7 to 30 day authorization period.

***

## Authorizations

With Extended Authorizations, you may capture payments beyond seven days on most card types for a small fee. For more information, refer to [Credit card authorization periods](https://help.shopify.com/en/manual/payments/payment-authorization#credit-card-authorization-period).

You can also use the Order Authorization API to [void an authorization](https://shopify.dev/docs/api/admin-graphql/latest/mutations/transactionVoid) and then [replace it with a new authorization](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderCreateMandatePayment).

By combining partial captures using `"finalCapture": true` with the Order Authorization API to create new authorizations, you can re-issue an authorization for the uncaptured amount, while also minimizing times where authorized amounts are held on a customer's card for items they've canceled before fulfillment.

While you may choose to re-issue authorizations immediately after void or expiration to maintain an active authorization, it isn't necessary. Authorizations can be re-issued on demand, as long as the total amount captured and total amount currently authorized is less than the order total.

***

## Fulfillment tracking

You can fetch an [order](https://shopify.dev/docs/api/admin-graphql/latest/queries/order) and [fulfillment order](https://shopify.dev/docs/api/admin-graphql/latest/objects/FulfillmentOrder) using the order ID.

If the order is shipped with a tracking number, then you must run the [`fulfillmentCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/fulfillmentCreate) mutation to update the tracking information and fulfill the order. You can make subsequent updates to the tracking information using the [`fulfillmentTrackingInfoUpdate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/fulfillmentTrackingInfoUpdate) mutation.

If the order is for store pickup, then you should instead run the [`fulfillmentOrderLineItemsPreparedForPickup`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/fulfillmentOrderLineItemsPreparedForPickup) mutation to update the status.

The following example creates a fulfillment with tracking information using the `fulfillmentCreate` mutation:

## fulfillmentCreate

```graphql
mutation fulfillmentCreate($fulfillment: FulfillmentInput!) {
  fulfillmentCreate(fulfillment: $fulfillment) {
    fulfillment {
      id
      status
      trackingInfo(first: 10) {
        company
        number
        url
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

## Input

```json
{
  "fulfillment": {
    "lineItemsByFulfillmentOrder": {
      "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/1"
    },
    "trackingInfo": {
      "company": "UPS",
      "number": "1Z001985YW99744790"
    }
  }
}
```

## Response

```json
{
  "fulfillmentCreate": {
    "fulfillment": {
      "id": "gid://shopify/Fulfillment/1",
      "status": "SUCCESS",
      "trackingInfo": [
        {
          "company": "UPS",
          "number": "1Z001985YW99744790",
          "url": "https://www.ups.com/WebTracking?loc=en_US&requester=ST&trackNums=1Z001985YW99744790"
        }
      ]
    },
    "userErrors": []
  }
}
```

The following example shows how to use the `fulfillmentOrderLineItemsPreparedForPickup` mutation:

## fulfillmentOrderLineItemsPreparedForPickup

```graphql
mutation fulfillmentOrderLineItemsPreparedForPickup($input: FulfillmentOrderLineItemsPreparedForPickupInput!) {
  fulfillmentOrderLineItemsPreparedForPickup(input: $input) {
    userErrors {
      field
      message
    }
  }
}
```

## Input

```json
{
  "input": {
    "lineItemsByFulfillmentOrder": [
      {
        "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/1046000776"
      }
    ]
  }
}
```

## Response

```json
{
  "fulfillmentOrderLineItemsPreparedForPickup": {
    "userErrors": []
  }
}
```

***

## Refund creation

Using the order ID returned from a completed checkout, you can run the [`refundCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/refundCreate) mutation:

## refundCreate

```graphql
mutation refundCreate($input: RefundInput!) {
  refundCreate(input: $input) {
    refund {
      id
      transactions(first: 10) {
        nodes {
          id
          kind
          status
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

## Input

```json
{
  "input": {
    "currency": "USD",
    "note": "Customer returned item",
    "orderId": "gid://shopify/Order/1",
    "transactions": [
      {
        "amount": "10.00",
        "gateway": "shopify_payments",
        "kind": "REFUND",
        "orderId": "gid://shopify/Order/1",
        "parentId": "gid://shopify/OrderTransaction/2"
      }
    ]
  }
}
```

## Response

```json
{
  "refundCreate": {
    "refund": {
      "id": "gid://shopify/Refund/1",
      "transactions": {
        "nodes": [
          {
            "id": "gid://shopify/OrderTransaction/3",
            "kind": "REFUND",
            "status": "SUCCESS"
          }
        ]
      }
    },
    "userErrors": []
  }
}
```

***

## Cancelling and deleting orders

You can cancel orders in Shopify using the asynchronous [`orderCancel`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderCancel) mutation, which effectively stops the order from being further processed in Shopify:

## orderCancel

```graphql
mutation OrderCancel($orderId: ID!, $notifyCustomer: Boolean, $refund: Boolean!, $restock: Boolean!, $reason: OrderCancelReason!, $staffNote: String) {
  orderCancel(orderId: $orderId, notifyCustomer: $notifyCustomer, refund: $refund, restock: $restock, reason: $reason, staffNote: $staffNote) {
    job {
      id
      done
    }
    jobResult {
      id
      done
    }
    orderCancelUserErrors {
      field
      message
      code
    }
  }
}
```

## Input

```json
{
  "orderId": "gid://shopify/Order/148977776",
  "notifyCustomer": true,
  "refund": true,
  "restock": true,
  "reason": "CUSTOMER",
  "staffNote": "Wrong size. Customer reached out saying they already re-purchased the correct size."
}
```

## Response

```json
{
  "orderCancel": {
    "job": {
      "id": "gid://shopify/Job/070bcd56-de0e-4985-bae8-c05be6365748",
      "done": false
    },
    "jobResult": {
      "id": "gid://shopify/OrderCancelJobResult/884324524",
      "done": false
    },
    "orderCancelUserErrors": []
  }
}
```

***
