Skip to content

Commit 7a8c082

Browse files
committed
Correct refund method
1 parent bbe7a94 commit 7a8c082

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ as methods on the client object. The following methods are currently available:
126126
| :------------------------- | :--------------------------------------------------- |
127127
| Create or update an order | `#create_or_update_order(email, options = {})` |
128128
| Create or update a batch of orders | `#create_or_update_orders(orders = {})` |
129-
| Create or update a refund | `#create_or_update_refund(order_id, amount, options = {})` |
129+
| Create or update a refund | `#create_or_update_refund(options = {})` |
130130

131131
#### Subscribers
132132

lib/drip/client/orders.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ def create_or_update_orders(orders)
2626

2727
# Public: Create or update a refund.
2828
#
29-
# order_id - Required. The String id of the order.
30-
# amount - Required. The amount of the refund.
31-
# options - Optional. A Hash of refund properties
32-
# upstream_id - The unique id of refund in the order management system.
33-
# note - A note about the refund.
34-
# processed_at - The String time at which the refund was processed in
35-
# ISO-8601 format.
29+
# options - Required. A Hash of refund properties
30+
# amount - Required. The amount of the refund.
31+
# provider - Required. The provider for the Order being refunded.
32+
# order_upstream_id - Required. The upstream_id for the Order being refunded.
33+
# upstream_id - The unique id of refund in the order management system.
34+
# note - A note about the refund.
35+
# processed_at - The String time at which the refund was processed in
36+
# ISO-8601 format.
3637
#
3738
# Returns a Drip::Response.
3839
# See https://developer.drip.com/#create-or-update-a-refund
39-
def create_or_update_refund(order_id, amount, options)
40-
data = options.merge(amount: amount)
41-
post "#{account_id}/orders/#{order_id}/refunds", generate_resource("refunds", data)
40+
def create_or_update_refund(options)
41+
post "#{account_id}/refunds", generate_resource("refunds", options)
4242
end
4343
end
4444
end

test/drip/client/orders_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ def setup
9494

9595
context "#create_or_update_refund" do
9696
setup do
97-
@amount = 4900
98-
@order_id = "98457h"
9997
@options = {
100-
"amount": @amount,
98+
"provider": "shopify",
99+
"order_upstream_id": "abcdef",
100+
"amount": 4900,
101101
"upstream_id": "tuvwx",
102102
"note": "Incorrect size",
103103
"processed_at": "2013-06-22T10:41:11Z"
@@ -107,14 +107,14 @@ def setup
107107
@response_status = 202
108108
@response_body = stub
109109

110-
@stubs.post "12345/orders/#{@order_id}/refunds", @payload do
110+
@stubs.post "12345/refunds", @payload do
111111
[@response_status, {}, @response_body]
112112
end
113113
end
114114

115115
should "send the correct request" do
116116
expected = Drip::Response.new(@response_status, @response_body)
117-
assert_equal expected, @client.create_or_update_refund(@order_id, @amount, @options)
117+
assert_equal expected, @client.create_or_update_refund(@options)
118118
end
119119
end
120120
end

0 commit comments

Comments
 (0)