Merge pull request #364 from stripe/brandur-deprecate-refund-helpers

Deprecate `#refund` helpers on `Charge` and `ApplicationFee`
This commit is contained in:
Brandur 2016-01-19 15:46:54 -08:00
commit 52a26ff08f
4 changed files with 15 additions and 17 deletions

View File

@ -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
def capture(params={}, opts={})

View File

@ -206,12 +206,12 @@ module Stripe
opts[:headers][:authorization] == 'Bearer local'
end.returns(make_response(make_charge))
Stripe.expects(:execute_request).with do |opts|
opts[:url] == "#{Stripe.api_base}/v1/charges/ch_test_charge/refund" &&
opts[:url] == "#{Stripe.api_base}/v1/charges/ch_test_charge/refunds" &&
opts[:headers][:authorization] == 'Bearer local'
end.returns(make_response(make_charge))
end.returns(make_response(make_refund))
ch = Stripe::Charge.retrieve('ch_test_charge', 'local')
ch.refund
ch.refunds.create
end
end
end

View File

@ -14,18 +14,12 @@ module Stripe
should "application fees should be refundable" do
fee = Stripe::ApplicationFee.construct_from(make_application_fee)
# first a post to create a refund
@mock.expects(:post).once.
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}/refunds", nil, '').
returns(make_response(make_application_fee_refund))
# then a get to refresh the current object
@mock.expects(:get).once.
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}", nil, nil).
returns(make_response({:id => "fee_test_fee", :refunded => true}))
fee.refund
assert fee.refunded
refund = fee.refunds.create
assert refund.is_a?(Stripe::ApplicationFeeRefund)
end
end
end

View File

@ -12,11 +12,11 @@ module Stripe
end
should "charges should be refundable" do
c = Stripe::Charge.construct_from(make_charge)
@mock.expects(:get).never
@mock.expects(:post).once.returns(make_response({:id => "ch_test_charge", :refunded => true}))
c = Stripe::Charge.new("test_charge")
c.refund
assert c.refunded
@mock.expects(:post).once.returns(make_response(make_refund(:charge => c)))
r = c.refunds.create
assert r.is_a?(Stripe::Refund)
end
should "charges should not be deletable" do