我正在处理我的应用程序针对特定缺货产品的退款。发布退款的 API 调用似乎仍然存在,但当我检查订单时,Shopify 中没有出现任何内容。
我有一个名为“refund_line_items”的数组中要退款的行项目,我从中映射各个项目以进行调用。
这是我的代码:
refund_calculation = ShopifyAPI::Refund.calculate({
currency: "USD",
notify: false,
note: "Out of stock",
shipping: {
"full_refund": false
},
refund_line_items: refund_line_items.map { |li|
{
line_item_id: li.id,
quantity: li.quantity,
restock_type: 'no_restock',
}
},
}, {
params: { order_id: shopify_order.id },
})
order_refund = ShopifyAPI::Refund.new({
currency: "USD",
notify: false,
note: "Out of stock",
shipping: {
"full_refund": false
},
refund_line_items: refund_line_items.map { |li|
{
line_item_id: li.id,
quantity: li.quantity,
restock_type: 'no_restock'
}
},
transactions: refund_calculation.transactions.map { |tr|
{
kind: "refund",
gateway: tr.gateway,
parent_id: tr.parent_id,
amount: tr.amount
}
},
}, {
params: { order_id: shopify_order.id }
})
这是退款后 API 调用之一的输出:
#<ShopifyAPI::Refund:0x0000561b935e4700
@attributes=
{"currency"=>"USD",
"notify"=>false,
"note"=>"Out of stock",
"shipping"=>
#<ShopifyAPI::Refund::Shipping:0x0000561b935e40c0
@attributes={"full_refund"=>false},
@persisted={:params=>{:order_id=>2528875905114}},
@prefix_options={}>,
"refund_line_items"=>
[#<ShopifyAPI::Refund::RefundLineItem:0x0000561b935ef830
@attributes=
{"line_item_id"=>5596452192346,
"quantity"=>1,
"restock_type"=>"no_restock"},
@persisted={:params=>{:order_id=>2528875905114}},
@prefix_options={}>],
"transactions"=>
[#<ShopifyAPI::Transaction:0x0000561b935ef038
@attributes=
{"kind"=>"refund",
"gateway"=>"shopify_payments",
"parent_id"=>3161136562266,
"amount"=>"11.72"},
@persisted={:params=>{:order_id=>2528875905114}},
@prefix_options={}>]},
@persisted={:params=>{:order_id=>2528875905114}},
@prefix_options={}>
从这个输出看,退款似乎是持久的,但在检查时它实际上并没有持久。我在这里做错了什么?谢谢。