mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-08 00:01:02 -05:00
I'm not sure exactly what changed here (did we change the `$VERBOSE` setting?), but I'm not seeing a whole lot of warnings when running the test suites locally and in CI. For example: ``` Started ........................................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ............../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized .../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ... ..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ......./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ........../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized .../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized .......... ........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized ............./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized ./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized ...................../home/travis/build/stripe/stripe-ruby/lib/stripe/transfer.rb:8: warning: instance variable @api_key not initialized .............. .. Finished in 0.785621037 seconds. ``` Most of these are due to unused or uninitialized variables. This patch fixes all warnings by fixing offending code.
81 lines
2.3 KiB
Ruby
81 lines
2.3 KiB
Ruby
module Stripe
|
|
class Charge < APIResource
|
|
extend Stripe::APIOperations::List
|
|
extend Stripe::APIOperations::Create
|
|
include Stripe::APIOperations::Update
|
|
|
|
def refund(params={}, opts={})
|
|
# Old versions of charge objects included a `refunds` field that was just
|
|
# a vanilla array instead of a Stripe list object.
|
|
#
|
|
# Where possible, we'd still like to use the new refund endpoint (thus
|
|
# `self.refunds.create`), but detect the old API version by looking for
|
|
# an `Array` and fall back to the old refund URL if necessary so as to
|
|
# maintain internal compatibility.
|
|
unless self.refunds.is_a?(Array)
|
|
self.refunds.create(params, 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
|
|
else
|
|
response, opts = request(:post, refund_url, params, opts)
|
|
initialize_from(response, opts)
|
|
end
|
|
end
|
|
|
|
def capture(params={}, opts={})
|
|
response, opts = request(:post, capture_url, params, opts)
|
|
initialize_from(response, opts)
|
|
end
|
|
|
|
def update_dispute(params={}, opts={})
|
|
response, opts = request(:post, dispute_url, params, opts)
|
|
initialize_from({ :dispute => response }, opts, true)
|
|
dispute
|
|
end
|
|
|
|
def close_dispute(params={}, opts={})
|
|
response, opts = request(:post, close_dispute_url, params, opts)
|
|
initialize_from(response, opts)
|
|
end
|
|
|
|
def mark_as_fraudulent
|
|
params = {
|
|
:fraud_details => { :user_report => 'fraudulent' }
|
|
}
|
|
response, opts = request(:post, resource_url, params)
|
|
initialize_from(response, opts)
|
|
end
|
|
|
|
def mark_as_safe
|
|
params = {
|
|
:fraud_details => { :user_report => 'safe' }
|
|
}
|
|
response, opts = request(:post, resource_url, params)
|
|
initialize_from(response, opts)
|
|
end
|
|
|
|
private
|
|
|
|
def capture_url
|
|
resource_url + '/capture'
|
|
end
|
|
|
|
def dispute_url
|
|
resource_url + '/dispute'
|
|
end
|
|
|
|
def close_dispute_url
|
|
resource_url + '/dispute/close'
|
|
end
|
|
|
|
# Note that this is actually the *old* refund URL and its use is no longer
|
|
# preferred.
|
|
def refund_url
|
|
resource_url + '/refund'
|
|
end
|
|
end
|
|
end
|