Version: 2024-10
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 AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) { appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) { userErrors { field message } appPurchaseOneTime { createdAt id } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"1000 imported orders.\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {\n appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) {\n userErrors {\n field\n message\n }\n appPurchaseOneTime {\n createdAt\n id\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"1000 imported orders.\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n },\n },\n});\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 AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {\n appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) {\n userErrors {\n field\n message\n }\n appPurchaseOneTime {\n createdAt\n id\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"1000 imported orders.\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {\n appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) {\n userErrors {\n field\n message\n }\n appPurchaseOneTime {\n createdAt\n id\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"1000 imported orders.\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"price\" => [\n \"amount\" => 10.0,\n \"currencyCode\" => \"USD\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {\n appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) {\n userErrors {\n field\n message\n }\n appPurchaseOneTime {\n createdAt\n id\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"1000 imported orders.\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppPurchaseOneTimeCreate($name: String!, $price: MoneyInput!, $returnUrl: URL!) {\n appPurchaseOneTimeCreate(name: $name, returnUrl: $returnUrl, price: $price) {\n userErrors {\n field\n message\n }\n appPurchaseOneTime {\n createdAt\n id\n }\n confirmationUrl\n }\n}"
input: { "name": "1000 imported orders.", "returnUrl": "http://super-duper.shopifyapps.com/", "price": { "amount": 10.0, "currencyCode": "USD" } }
response: { "data": { "appPurchaseOneTimeCreate": { "userErrors": [], "appPurchaseOneTime": { "createdAt": "2024-11-21T22:47:04Z", "id": "gid://shopify/AppPurchaseOneTime/1017262352" }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/193172482/1017262352/ApplicationCharge/confirm_application_charge?signature=BAh7BzoHaWRpBBAxojw6EmF1dG9fYWN0aXZhdGVU--a03eedf9ef12d714906af085ebc2aa3d97aa9466" } } }