Sha256: 1fa9b53fa56555e501830171116a55711fad92a05afe1a0883198ce72ce6265c

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

module Stripe
  class Charge < APIResource
    include Stripe::APIOperations::List
    include Stripe::APIOperations::Create
    include Stripe::APIOperations::Update

    def refund(params={})
      response, api_key = Stripe.request(:post, refund_url, @api_key, params)
      refresh_from(response, api_key)
      self
    end

    def capture(params={})
      response, api_key = Stripe.request(:post, capture_url, @api_key, params)
      refresh_from(response, api_key)
      self
    end

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

    def close_dispute
      response, api_key = Stripe.request(:post, close_dispute_url, @api_key)
      refresh_from(response, api_key)
      self
    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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
stripe-1.16.0 lib/stripe/charge.rb
stripe-1.15.0 lib/stripe/charge.rb
stripe-1.14.0 lib/stripe/charge.rb
stripe-1.13.0 lib/stripe/charge.rb
stripe-1.12.0 lib/stripe/charge.rb
stripe-1.11.0 lib/stripe/charge.rb
stripe-1.10.1 lib/stripe/charge.rb
stripe-1.10.0 lib/stripe/charge.rb
stripe-1.9.9 lib/stripe/charge.rb
stripe-1.8.8 lib/stripe/charge.rb
stripe-1.8.7 lib/stripe/charge.rb