为什么我被禁止使用 Shopify API Ruby Gem 创建结帐
Why am I forbidden from creating a checkout using the Shopify API Ruby Gem
有人在使用 Shopify API rub gem 吗?我正在建立一个无头店面,几乎没有什么东西不起作用。我可以获取产品,但无法创建结帐,因此我可以将商品添加到购物车。
Ruby:2.7.0
Rails: 6.0.2.1
设置:
config/initializers/shopify.rb:
shop_url = "https://#{ENV['SHOPIFY_API_KEY']}:#{ENV['SHOPIFY_PASSWORD']}@#{ENV['SHOP_NAME']}.myshopify.com"
ShopifyAPI::Base.site = shop_url
ShopifyAPI::Base.api_version = ENV['STORE_API_VERSION'] # find the latest stable api_version [here](https://help.shopify.com/api/versioning)
以上是我使用私人应用程序时的文档。
在控制器中:
product = ShopifyAPI::Product.find('12345678')
# This works fine. Now:
checkout = ShopifyAPI::Checkout.create
# <ActiveResource::ForbiddenAccess: Failed. Response code = 403. Response message = Forbidden.>
我从 their tests 得到的 create
但它是 "blowing up"。
我试图了解如何将商品添加到购物车,their JS example 显示在页面加载时,他们创建了一个结帐,然后在将商品添加到购物车时使用它 id
。
虽然我的前端是JS,但一切都贯穿Rails.
谢谢。
Checkout API 需要您的 APP public。
此外,您的应用必须设置为销售渠道(私有应用无法做到这一点,这就是您需要 public 的原因)并且您的产品必须可用于该销售渠道,以便将它们添加到结帐。
作为替代方案,您可以使用店面 API https://help.shopify.com/en/api/storefront-api/reference/mutation/checkoutcreate
有人在使用 Shopify API rub gem 吗?我正在建立一个无头店面,几乎没有什么东西不起作用。我可以获取产品,但无法创建结帐,因此我可以将商品添加到购物车。
Ruby:2.7.0 Rails: 6.0.2.1
设置:
config/initializers/shopify.rb:
shop_url = "https://#{ENV['SHOPIFY_API_KEY']}:#{ENV['SHOPIFY_PASSWORD']}@#{ENV['SHOP_NAME']}.myshopify.com"
ShopifyAPI::Base.site = shop_url
ShopifyAPI::Base.api_version = ENV['STORE_API_VERSION'] # find the latest stable api_version [here](https://help.shopify.com/api/versioning)
以上是我使用私人应用程序时的文档。
在控制器中:
product = ShopifyAPI::Product.find('12345678')
# This works fine. Now:
checkout = ShopifyAPI::Checkout.create
# <ActiveResource::ForbiddenAccess: Failed. Response code = 403. Response message = Forbidden.>
我从 their tests 得到的 create
但它是 "blowing up"。
我试图了解如何将商品添加到购物车,their JS example 显示在页面加载时,他们创建了一个结帐,然后在将商品添加到购物车时使用它 id
。
虽然我的前端是JS,但一切都贯穿Rails.
谢谢。
Checkout API 需要您的 APP public。
此外,您的应用必须设置为销售渠道(私有应用无法做到这一点,这就是您需要 public 的原因)并且您的产品必须可用于该销售渠道,以便将它们添加到结帐。
作为替代方案,您可以使用店面 API https://help.shopify.com/en/api/storefront-api/reference/mutation/checkoutcreate