mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-07 00:05:33 -04:00
Lets not be too shy about just using `extend` instead of `include` here when it's more appropriate to do so. The advantage to this approach is that the module can be either extended _or_ included with this change, but couldn't be without it due to the `ClassMethods` meta-magic. List has already started doing this as of #314, so we don't have to be afraid of breaking convention here.
63 lines
1.4 KiB
Ruby
63 lines
1.4 KiB
Ruby
module Stripe
|
|
class Charge < APIResource
|
|
extend Stripe::APIOperations::List
|
|
extend Stripe::APIOperations::Create
|
|
include Stripe::APIOperations::Update
|
|
|
|
def refund(params={}, opts={})
|
|
response, opts = request(:post, refund_url, params, opts)
|
|
refresh_from(response, opts)
|
|
end
|
|
|
|
def capture(params={}, opts={})
|
|
response, opts = request(:post, capture_url, params, opts)
|
|
refresh_from(response, opts)
|
|
end
|
|
|
|
def update_dispute(params={}, opts={})
|
|
response, opts = request(:post, dispute_url, params, opts)
|
|
refresh_from({ :dispute => response }, opts, true)
|
|
dispute
|
|
end
|
|
|
|
def close_dispute(params={}, opts={})
|
|
response, opts = request(:post, close_dispute_url, params, opts)
|
|
refresh_from(response, opts)
|
|
end
|
|
|
|
def mark_as_fraudulent
|
|
params = {
|
|
:fraud_details => { :user_report => 'fraudulent' }
|
|
}
|
|
response, opts = request(:post, url, params)
|
|
refresh_from(response, opts)
|
|
end
|
|
|
|
def mark_as_safe
|
|
params = {
|
|
:fraud_details => { :user_report => 'safe' }
|
|
}
|
|
response, opts = request(:post, url, params)
|
|
refresh_from(response, opts)
|
|
end
|
|
|
|
private
|
|
|
|
def refund_url
|
|
url + '/refund'
|
|
end
|
|
|
|
def capture_url
|
|
url + '/capture'
|
|
end
|
|
|
|
def dispute_url
|
|
url + '/dispute'
|
|
end
|
|
|
|
def close_dispute_url
|
|
url + '/dispute/close'
|
|
end
|
|
end
|
|
end
|