mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-29 00:01:18 -05:00
Also re-implement Charge#refund to use our new endpoint
This was already done for `ApplicationFee`.
This commit is contained in:
parent
8a20ab8972
commit
cd9d2bc71e
@ -5,8 +5,12 @@ module Stripe
|
||||
include Stripe::APIOperations::Update
|
||||
|
||||
def refund(params={}, opts={})
|
||||
response, opts = request(:post, refund_url, params, opts)
|
||||
initialize_from(response, opts)
|
||||
self.refunds.create
|
||||
|
||||
# now that a refund has been created, we expect the state of this object
|
||||
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
||||
# from the server
|
||||
self.refresh
|
||||
end
|
||||
extend Gem::Deprecate
|
||||
deprecate :refund, "charge.refunds.create", 2016, 07
|
||||
|
||||
@ -28,7 +28,8 @@ module Stripe
|
||||
begin
|
||||
fee = Stripe::ApplicationFee.construct_from(make_application_fee)
|
||||
|
||||
# creates the refund
|
||||
# creates the refund (this is not how the endpoint would actually
|
||||
# respond, but we discard the result anyway)
|
||||
@mock.expects(:post).once.
|
||||
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}/refunds", nil, '').
|
||||
returns(make_response({}))
|
||||
|
||||
@ -120,9 +120,18 @@ module Stripe
|
||||
$stderr = StringIO.new
|
||||
begin
|
||||
charge = Stripe::Charge.construct_from(make_charge)
|
||||
|
||||
# creates the refund (this is not how the endpoint would actually
|
||||
# respond, but we discard the result anyway)
|
||||
@mock.expects(:post).once.
|
||||
with("#{Stripe.api_base}/v1/charges/#{charge.id}/refund", nil, '').
|
||||
with("#{Stripe.api_base}/v1/charges/#{charge.id}/refunds", nil, '').
|
||||
returns(make_response({}))
|
||||
|
||||
# reloads the charge to get the field updates
|
||||
@mock.expects(:get).once.
|
||||
with("#{Stripe.api_base}/v1/charges/#{charge.id}", nil, nil).
|
||||
returns(make_response({:id => charge.id, :refunded => true}))
|
||||
|
||||
charge.refund
|
||||
message = "NOTE: Stripe::Charge#refund is deprecated; use " +
|
||||
"charge.refunds.create instead"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user