store Credit Account Debitmutation
mutation
2024-10latest
Requires write
access scope.
Creates a debit transaction that decreases the store credit account balance by the given amount.
Arguments
The input fields for a store credit account debit transaction.
The ID of the store credit account or the ID of the account owner.
Was this section helpful?
StoreCreditAccountDebitPayload returns
Anchor to StoreCreditAccountDebitPayload.storeCreditAccountTransactionstoreCredit Account Transaction The store credit account transaction that was created.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: storeCreditAccountDebit
Query Reference for MUTATION: storeCreditAccountDebit
"mutation storeCreditAccountDebit($debitInput: StoreCreditAccountDebitInput!, $id: ID!) {\n storeCreditAccountDebit(debitInput: $debitInput, id: $id) {\n storeCreditAccountTransaction {\n # StoreCreditAccountDebitTransaction fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: storeCreditAccountDebit
"{\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n }\n },\n \"id\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: storeCreditAccountDebit
"input StoreCreditAccountDebitInput {\n debitAmount: MoneyInput!\n}\n\ninput MoneyInput {\n amount: Decimal!\n currencyCode: CurrencyCode!\n}\n"
Display Examples for MUTATION: storeCreditAccountDebit
[ { "example": { "type_name": "storecreditaccountdebit", "title": "Debit a store credit account by account ID", "query_string": "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}", "variables": { "id": "gid://shopify/StoreCreditAccount/316863792", "debitInput": { "debitAmount": { "amount": "9.99", "currencyCode": "USD" } } }, "response": { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": { "amount": { "amount": "-9.99", "currencyCode": "USD" }, "account": { "id": "gid://shopify/StoreCreditAccount/316863792", "balance": { "amount": "1.12", "currencyCode": "USD" } } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-07", "maximum_api_version": "unstable", "location": "/components/stored_value_instruments/store_credit/test/unit/models/graph_api/admin/mutations/store_credit_account_debit_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\" => [\n \"debitAmount\" => [\n \"amount\" => \"9.99\",\n \"currencyCode\" => \"USD\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the store credit account or the ID of the account owner.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/StoreCreditAccount/316863792\"", "typeKind": "MUTATION" }, { "arg": { "name": "debitInput", "description": "The input fields for a store credit account debit transaction.", "type": { "kind": "INPUT_OBJECT", "name": "StoreCreditAccountDebitInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "StoreCreditAccountDebitInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "debitInput", "argValue": " {\"debitAmount\":{\"amount\":\"9.99\",\"currencyCode\":\"USD\"}}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "storecreditaccountdebit", "title": "Debit a store credit account by customer ID", "query_string": "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}", "variables": { "id": "gid://shopify/Customer/544365967", "debitInput": { "debitAmount": { "amount": "9.99", "currencyCode": "USD" } } }, "response": { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": { "amount": { "amount": "-9.99", "currencyCode": "USD" }, "account": { "id": "gid://shopify/StoreCreditAccount/316863792", "balance": { "amount": "1.12", "currencyCode": "USD" } } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-07", "maximum_api_version": "unstable", "location": "/components/stored_value_instruments/store_credit/test/unit/models/graph_api/admin/mutations/store_credit_account_debit_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Customer/544365967\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"9.99\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/Customer/544365967\",\n \"debitInput\" => [\n \"debitAmount\" => [\n \"amount\" => \"9.99\",\n \"currencyCode\" => \"USD\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the store credit account or the ID of the account owner.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "MUTATION" }, { "arg": { "name": "debitInput", "description": "The input fields for a store credit account debit transaction.", "type": { "kind": "INPUT_OBJECT", "name": "StoreCreditAccountDebitInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "StoreCreditAccountDebitInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "debitInput", "argValue": " {\"debitAmount\":{\"amount\":\"9.99\",\"currencyCode\":\"USD\"}}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "storecreditaccountdebit", "title": "Debiting an amount that exceeds the account balance returns an error", "query_string": "mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}", "variables": { "id": "gid://shopify/StoreCreditAccount/316863792", "debitInput": { "debitAmount": { "amount": "100.00", "currencyCode": "USD" } } }, "response": { "data": { "storeCreditAccountDebit": { "storeCreditAccountTransaction": null, "userErrors": [ { "message": "The store credit account does not have sufficient funds to satisfy the request", "field": [ "debitInput", "debitAmount", "amount" ] } ] } } }, "api_name": "admin", "minimum_api_version": "2024-07", "maximum_api_version": "unstable", "location": "/components/stored_value_instruments/store_credit/test/unit/models/graph_api/admin/mutations/store_credit_account_debit_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) { storeCreditAccountDebit(id: $id, debitInput: $debitInput) { storeCreditAccountTransaction { amount { amount currencyCode } account { id balance { amount currencyCode } } } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\": {\n \"debitAmount\": {\n \"amount\": \"100.00\",\n \"currencyCode\": \"USD\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation storeCreditAccountDebit($id: ID!, $debitInput: StoreCreditAccountDebitInput!) {\n storeCreditAccountDebit(id: $id, debitInput: $debitInput) {\n storeCreditAccountTransaction {\n amount {\n amount\n currencyCode\n }\n account {\n id\n balance {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/StoreCreditAccount/316863792\",\n \"debitInput\" => [\n \"debitAmount\" => [\n \"amount\" => \"100.00\",\n \"currencyCode\" => \"USD\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the store credit account or the ID of the account owner.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/StoreCreditAccount/316863792\"", "typeKind": "MUTATION" }, { "arg": { "name": "debitInput", "description": "The input fields for a store credit account debit transaction.", "type": { "kind": "INPUT_OBJECT", "name": "StoreCreditAccountDebitInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "StoreCreditAccountDebitInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "debitInput", "argValue": " {\"debitAmount\":{\"amount\":\"100.00\",\"currencyCode\":\"USD\"}}", "typeKind": "MUTATION" } ] } ]