shopify - 如何使用 Shopify API 创建结帐
问题描述
通过 Postman,我根据 Shopify 文档的此页面将 GraphQL 发送到适当的端点:使用 Storefront API 创建结帐。我收到以下回复:
{
"errors": "[API] This action requires merchant approval for write_checkouts scope."
}
如果应用程序需要转换为销售渠道或公共应用程序,请告诉我如何完成。谢谢你的帮助!
解决方案
我不相信私人或自定义应用程序可以做到这一点。您的应用必须是公开的。这里的一些附加信息: https ://community.shopify.com/c/shopify-apis-and-sdks/how-to-grant-write-checkouts-permission/td-p/448587
以下链接的要求部分提到您的应用必须是公开的: https ://shopify.dev/apps/channels/getting-started
再三考虑,StoreFront API 有 createCart: https ://shopify.dev/custom-storefronts/cart#create-a-cart-and-add-a-line-item
我创建了一个私人应用程序并使用了以下内容:
帖子:https://[storename].myshopify.com/api/2021-10/graphql.json
添加标题:X-Shopify-Storefront-Access-Token:somevalue
设置主体:
mutation MyMutation1 {
cartCreate(input: {lines: {merchandiseId: "someproducytid==",quantity:1}, buyerIdentity: {email: "test@test.com"}}) {
cart {
id
checkoutUrl
buyerIdentity {
customer {
email
}
}
}
}
}
推荐阅读
- c# - 在使用 asp.net 的 GridView 中显示名称而不是 Id,其值存在于不同的表中
- javascript - 如何清除嵌套状态内的数组?
- javascript - 如何在 jQuery 中使用 append 添加多个名称?
- android - 具有回收站视图或列表视图的下载管理器
- solidity - 如何访问具有数组类型值的 Solidity 映射?
- sql-server - SQL server 函数 - 以列名作为输入参数
- javascript -
不会从路由中删除 hashbang - javascript - 如何获取对子 dom 元素的引用
- android - 释放模式下由于内存问题导致应用程序崩溃
- angularjs - 重用 http 调用的结果