Skip to content

Instantly share code, notes, and snippets.

@mfifth
Created July 21, 2017 00:06
Show Gist options
  • Select an option

  • Save mfifth/39189873bcdfadd202a64f0a59a0e3d5 to your computer and use it in GitHub Desktop.

Select an option

Save mfifth/39189873bcdfadd202a64f0a59a0e3d5 to your computer and use it in GitHub Desktop.
#<HTTParty::Response:0x7fffdbcc0bb8 parsed_response={"errors"=>{"base"=>["either refund line items or transactions must be present"]}}
class Shop
def self.refund_order(order_id, shopify_token, shopify_domain, line_item_ids)
data = {
"refund" => {
"restock" => false,
"notify" => true,
"note" => "Manual refund",
},
"shipping" => {
"full_refund" => true
},
"refund_line_items" => [
line_item_ids.each do |line_item_id|
{
"line_item_id" => line_item_id,
"quantity" => 1
}
end
]
}
headers = {"X-Shopify-Access-Token" => shopify_token}
url = "https://#{shopify_domain}/admin/orders/#{order_id}/refunds.json"
results = HTTParty.post(url, headers: headers, body: data)
return results
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment