Sha256: 69e421a7a9f0efd7bec42bef4936156df94c1355c4f5cba4ec05289626345019

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'open_pay_resource'

class Charges < OpenPayResource

  def all(customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.all_charges(customer_id)
    else
      super ''
    end
  end


  def cancel(transaction_id,customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.cancel_charge(customer_id, transaction_id)
    else
         post('', transaction_id+'/cancel')
     end
  end


  def refund(transaction_id,description,customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.refund_charge(customer_id,transaction_id,description)
    else
      post(description, transaction_id+'/refund')
    end
  end


  def capture(transaction_id,customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.capture_charge(customer_id,transaction_id )
    else
      post(description, transaction_id+'/capture')
    end
  end




  def each(customer_id=nil)
    if customer_id
      all(customer_id).each do |card|
        yield card
      end
    else
      all.each do |card|
        yield card
      end
    end
  end



  def get(charge='', customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.get_charge(customer_id, charge)
    else
      super charge
    end
  end

  def create(charge, customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.create_charge(customer_id, charge)
    else
      super charge
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openpay-0.9.8 lib/OpenPay/Charges.rb