Sha256: 77772c13fa887ce51d2a12c2d3efedc0ef6be45411e035e4ec48f0a1bfd6fb7b

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

require_relative '../resource'

module Tickethub
  class Supplier::Payment < Resource
    path '/supplier/payments'

    require_relative 'charge'

    require_relative 'payment/cash'
    require_relative 'payment/credit'
    require_relative 'payment/direct'
    require_relative 'payment/stripe'
    require_relative 'payment/complimentary'

    require_relative 'order'
    require_relative 'user'

    association :order, Supplier::Order
    association :user, Supplier::User

    attribute :amount, type: :money
    attribute :refunded, type: :money
    attribute :currency, type: :currency
    attribute :refunded_at, type: :datetime
    attribute :created_at, type: :datetime
    attribute :updated_at, type: :datetime

    def refund(attributes)
      self.load @endpoint[:refund].post(attributes).decoded
      return true
    rescue Tickethub::ResourceInvalid => err
      self.load Tickethub::Response.new(err.response).decoded
      return false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tickethub-0.3.1 lib/tickethub/supplier/payment.rb
tickethub-0.3.0 lib/tickethub/supplier/payment.rb