Anchor to refundCreaterefund
refundCreate
mutation
Requires orders
access scope, access scope or
access scope.
Creates a refund.
Anchor to Arguments
Arguments
- Anchor to inputinput•Refund
Input! required The input fields that are used in the mutation for creating a refund.
Was this section helpful?
Anchor to RefundCreatePayload returnsRefundCreatePayload returns
- Anchor to orderorder•
The order associated with the created refund.
- Anchor to refundrefund•
The created refund.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a refund with a note and transaction, then return the total refund amount across all transactions
- Create a refund with shipping partially refunded. Then, return the total refund amount and information about the first two transactions.
- Creates a refund
- refundCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation M($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
note
totalRefundedSet {
presentmentMoney {
amount
}
}
}
}
}`,
{
variables: {
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/25746870",
mutation M($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
note
totalRefundedSet {
presentmentMoney {
amount
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation M($input: RefundInput!) { refundCreate(input: $input) { userErrors { field message } refund { id note totalRefundedSet { presentmentMoney { amount } } } } }",
"variables": {
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/25746870",
"quantity": 2
}
],
"transactions": [
{
"orderId": "gid://shopify/Order/734509473",
"gateway": "foo",
"kind": "REFUND",
"amount": "10.0",
"parentId": "gid://shopify/OrderTransaction/723599266"
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation M($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
note
totalRefundedSet {
presentmentMoney {
amount
}
}
}
}
}`,
{
variables: {
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/25746870",
"quantity": 2
}
],
"transactions": [
{
"orderId": "gid://shopify/Order/734509473",
"gateway": "foo",
"kind": "REFUND",
"amount": "10.0",
"parentId": "gid://shopify/OrderTransaction/723599266"
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation M($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
note
totalRefundedSet {
presentmentMoney {
amount
}
}
}
}
}`,
"variables": {
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/25746870",
"quantity": 2
}
],
"transactions": [
{
"orderId": "gid://shopify/Order/734509473",
"gateway": "foo",
"kind": "REFUND",
"amount": "10.0",
"parentId": "gid://shopify/OrderTransaction/723599266"
}
]
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation M($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
note
totalRefundedSet {
presentmentMoney {
amount
}
}
}
}
}
QUERY
variables = {
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [{"lineItemId"=>"gid://shopify/LineItem/25746870", "quantity"=>2}],
"transactions": [{"orderId"=>"gid://shopify/Order/734509473", "gateway"=>"foo", "kind"=>"REFUND", "amount"=>"10.0", "parentId"=>"gid://shopify/OrderTransaction/723599266"}]
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"orderId": "gid://shopify/Order/734509473",
"note": "Want to exchange for a different item",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/25746870",
"quantity": 2
}
],
"transactions": [
{
"orderId": "gid://shopify/Order/734509473",
"gateway": "foo",
"kind": "REFUND",
"amount": "10.0",
"parentId": "gid://shopify/OrderTransaction/723599266"
}
]
}
}
Response
JSON{
"refundCreate": {
"userErrors": [],
"refund": {
"id": "gid://shopify/Refund/929361479",
"note": "Want to exchange for a different item",
"totalRefundedSet": {
"presentmentMoney": {
"amount": "10.0"
}
}
}
}
}