mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-30 00:00:47 -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
|
include Stripe::APIOperations::Update
|
||||||
|
|
||||||
def refund(params={}, opts={})
|
def refund(params={}, opts={})
|
||||||
response, opts = request(:post, refund_url, params, opts)
|
self.refunds.create
|
||||||
initialize_from(response, opts)
|
|
||||||
|
# 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
|
end
|
||||||
extend Gem::Deprecate
|
extend Gem::Deprecate
|
||||||
deprecate :refund, "charge.refunds.create", 2016, 07
|
deprecate :refund, "charge.refunds.create", 2016, 07
|
||||||
|
|||||||
@ -28,7 +28,8 @@ module Stripe
|
|||||||
begin
|
begin
|
||||||
fee = Stripe::ApplicationFee.construct_from(make_application_fee)
|
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.
|
@mock.expects(:post).once.
|
||||||
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}/refunds", nil, '').
|
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}/refunds", nil, '').
|
||||||
returns(make_response({}))
|
returns(make_response({}))
|
||||||
|
|||||||
@ -120,9 +120,18 @@ module Stripe
|
|||||||
$stderr = StringIO.new
|
$stderr = StringIO.new
|
||||||
begin
|
begin
|
||||||
charge = Stripe::Charge.construct_from(make_charge)
|
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.
|
@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}))
|
returns(make_response({:id => charge.id, :refunded => true}))
|
||||||
|
|
||||||
charge.refund
|
charge.refund
|
||||||
message = "NOTE: Stripe::Charge#refund is deprecated; use " +
|
message = "NOTE: Stripe::Charge#refund is deprecated; use " +
|
||||||
"charge.refunds.create instead"
|
"charge.refunds.create instead"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user