Sha256: 5567fa22dcbc0a5bb29c3751c2e49e59ea50fdc905a7710bc9d9fed90dba7e89

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 Bytes

Contents

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

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

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

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

    private

    def refund_url
      url + '/refund'
    end

    def capture_url
      url + '/capture'
    end

    def dispute_url
      url + '/dispute'
    end

    def charges
      Event.all({ :charge_id => id }, @api_key)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conekta-0.3.3 lib/conekta/charge.rb
conekta-0.3.1 lib/conekta/charge.rb
conekta-0.3.0 lib/conekta/charge.rb