Class: Stripe::Charge

Inherits:
APIResource show all
Includes:
APIOperations::Create, APIOperations::List, APIOperations::Update
Defined in:
lib/stripe/charge.rb

Instance Attribute Summary

Attributes inherited from StripeObject

#api_key

Instance Method Summary collapse

Methods included from APIOperations::Update

#save, #serialize_metadata, #serialize_params

Methods included from APIOperations::Create

included

Methods included from APIOperations::List

included

Methods inherited from APIResource

class_name, #refresh, retrieve, url, #url

Methods inherited from StripeObject

#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Method Details

#capture(params = {}, opts = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/stripe/charge.rb', line 14

def capture(params={}, opts={})
  api_key, headers = Util.parse_opts(opts)
  response, api_key = Stripe.request(
    :post, capture_url, api_key || @api_key, params, headers)
  refresh_from(response, api_key)
end

#close_dispute(params = {}, opts = {}) ⇒ Object



29
30
31
32
33
34
# File 'lib/stripe/charge.rb', line 29

def close_dispute(params={}, opts={})
  api_key, headers = Util.parse_opts(opts)
  response, api_key = Stripe.request(
    :post, close_dispute_url, api_key || @api_key, params, headers)
  refresh_from(response, api_key)
end

#mark_as_fraudulentObject



36
37
38
39
40
41
42
# File 'lib/stripe/charge.rb', line 36

def mark_as_fraudulent
  params = {
    :fraud_details => { :user_report => 'fraudulent' }
  }
  response, api_key = Stripe.request(:post, url, @api_key, params)
  refresh_from(response, api_key)
end

#mark_as_safeObject



44
45
46
47
48
49
50
# File 'lib/stripe/charge.rb', line 44

def mark_as_safe
  params = {
    :fraud_details => { :user_report => 'safe' }
  }
  response, api_key = Stripe.request(:post, url, @api_key, params)
  refresh_from(response, api_key)
end

#refund(params = {}, opts = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/stripe/charge.rb', line 7

def refund(params={}, opts={})
  api_key, headers = Util.parse_opts(opts)
  response, api_key = Stripe.request(
    :post, refund_url, api_key || @api_key, params, headers)
  refresh_from(response, api_key)
end

#update_dispute(params = {}, opts = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/stripe/charge.rb', line 21

def update_dispute(params={}, opts={})
  api_key, headers = Util.parse_opts(opts)
  response, api_key = Stripe.request(
    :post, dispute_url, api_key || @api_key, params, headers)
  refresh_from({ :dispute => response }, api_key, true)
  dispute
end