【问题标题】:ShopifyAPI Gem calculate refundsShopifyAPI Gem 计算退款
【发布时间】:2019-11-01 11:17:17
【问题描述】:

我正在为我正在制作的应用程序使用shopify_api gem。退款过程完全在应用程序中处理,我只需要将 Shopify 上的订单更新为已退款。除了注册付款状态更改外,我不需要 Shopify 做任何事情。我已经读到我需要先在 gem 中使用Refund.calculate 来获取交易父 ID,然后才能实际向退款端点发出请求。我的问题是,在阅读文档时,我无法破译如何格式化 .calculate 请求的参数。这是 gem 中的相关方法。

module ShopifyAPI
  class Refund < Base
    init_prefix :order

    def self.calculate(*args)
      options = { :refund => args[0] }
      params = {}
      params = args[1][:params] if args[1] && args[1][:params]

      resource = post(:calculate, params, options.to_json)
      instantiate_record(format.decode(resource.body), {})
    end
  end
end

我尝试过 Refund.calculate({shipping: { full_refund: true }, currency: 'EUR', refund_line_items: [{line_item_id: 12344556, quantity: 1}, restock: true]}, params: {order_id: 23453245}) 我也尝试过 restock_type: 'restock' 我不断收到 406 或 422 错误。

【问题讨论】:

  • 你有没有想过这个问题?撞到同一堵墙
  • 我没有,我很抱歉 :(。我现在不得不提出这个功能。这对于我当前的项目来说更像是一个提前计划,以防客户希望应用程序之间完全同步和shopify。如果/当我弄清楚这一点时,我实际上会在我的项目中添加一个待办事项来更新这个问题
  • 感谢您的回复 - 如果遇到解决方案,我会更新您

标签: ruby-on-rails shopify


【解决方案1】:

我认为您的 refund_line_items 格式不正确。这是我使用的:

ShopifyAPI::Refund.calculate({
  refund_line_items: order.line_items.map { |li|
    {
      line_item_id: li.id,
      quantity: li.quantity,
      restock_type: 'cancel',
    }
  },
  shipping: { full_refund: true },
}, {
  params: { order_id: order.id },
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    • 1970-01-01
    相关资源
    最近更新 更多