Created
July 21, 2017 00:06
-
-
Save mfifth/39189873bcdfadd202a64f0a59a0e3d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #<HTTParty::Response:0x7fffdbcc0bb8 parsed_response={"errors"=>{"base"=>["either refund line items or transactions must be present"]}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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