Create a refund that's issued as a store credit
Description
Create a refund that's issued as store credit instead of returning it to the original payment method.
The store credit amount is specified in the `refundMethods` field and applies to a specific line item
in the order. The mutation returns the refund ID, total refunded amount, and transaction details
associated with the store credit.
Query
mutation RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}
Variables
{
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation RefundToStoreCredit($input: RefundInput!) { refundCreate(input: $input) { userErrors { field message } refund { id totalRefundedSet { presentmentMoney { amount currencyCode } } transactions(first: 2) { edges { node { gateway kind amountSet { presentmentMoney { amount currencyCode } } } } } } order { id } } }",
"variables": {
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}`,
{
variables: {
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}
QUERY
variables = {
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}`,
"variables": {
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}' \
--variables \
'{
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2025-10/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation RefundToStoreCredit($input: RefundInput!) {
refundCreate(input: $input) {
userErrors {
field
message
}
refund {
id
totalRefundedSet {
presentmentMoney {
amount
currencyCode
}
}
transactions(first: 2) {
edges {
node {
gateway
kind
amountSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
order {
id
}
}
}
`,
variables: {
"input": {
"orderId": "gid://shopify/Order/1073459983",
"refundLineItems": [
{
"lineItemId": "gid://shopify/LineItem/1071823193",
"quantity": 1
}
],
"transactions": [],
"refundMethods": [
{
"storeCreditRefund": {
"amount": {
"amount": "10.00",
"currencyCode": "USD"
}
}
}
]
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"refundCreate": {
"userErrors": [],
"refund": {
"id": "gid://shopify/Refund/943333862",
"totalRefundedSet": {
"presentmentMoney": {
"amount": "10.0",
"currencyCode": "USD"
}
},
"transactions": {
"edges": [
{
"node": {
"gateway": "shopify_store_credit",
"kind": "REFUND",
"amountSet": {
"presentmentMoney": {
"amount": "10.0",
"currencyCode": "USD"
}
}
}
}
]
}
},
"order": {
"id": "gid://shopify/Order/1073459983"
}
}
}