class Stripe::Charge

Constants

OBJECT_NAME

Public Instance Methods

capture(params = {}, opts = {}) click to toggle source
# File lib/stripe/resources/charge.rb, line 34
def capture(params = {}, opts = {})
  resp, opts = request(:post, capture_url, params, opts)
  initialize_from(resp.data, opts)
end
close_dispute(params = {}, opts = {}) click to toggle source
# File lib/stripe/resources/charge.rb, line 45
def close_dispute(params = {}, opts = {})
  resp, opts = request(:post, close_dispute_url, params, opts)
  initialize_from(resp.data, opts)
end
mark_as_fraudulent() click to toggle source
# File lib/stripe/resources/charge.rb, line 50
def mark_as_fraudulent
  params = {
    fraud_details: { user_report: "fraudulent" },
  }
  resp, opts = request(:post, resource_url, params)
  initialize_from(resp.data, opts)
end
mark_as_safe() click to toggle source
# File lib/stripe/resources/charge.rb, line 58
def mark_as_safe
  params = {
    fraud_details: { user_report: "safe" },
  }
  resp, opts = request(:post, resource_url, params)
  initialize_from(resp.data, opts)
end
refund(params = {}, opts = {}) click to toggle source
# File lib/stripe/resources/charge.rb, line 13
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.
  if refunds.is_a?(Array)
    resp, opts = request(:post, refund_url, params, opts)
    initialize_from(resp.data, opts)
  else
    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
    refresh
  end
end
update_dispute(params = {}, opts = {}) click to toggle source
# File lib/stripe/resources/charge.rb, line 39
def update_dispute(params = {}, opts = {})
  resp, opts = request(:post, dispute_url, params, opts)
  initialize_from({ dispute: resp.data }, opts, true)
  dispute
end

Private Instance Methods

capture_url() click to toggle source
# File lib/stripe/resources/charge.rb, line 66
        def capture_url
  resource_url + "/capture"
end
close_dispute_url() click to toggle source
# File lib/stripe/resources/charge.rb, line 74
        def close_dispute_url
  resource_url + "/dispute/close"
end
dispute_url() click to toggle source
# File lib/stripe/resources/charge.rb, line 70
        def dispute_url
  resource_url + "/dispute"
end
refund_url() click to toggle source

Note that this is actually the old refund URL and its use is no longer preferred.

# File lib/stripe/resources/charge.rb, line 80
        def refund_url
  resource_url + "/refund"
end