Class: VendorTicketTransactionPayment

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Defined in:
app/models/vendor_ticket_transaction_payment.rb

Overview

Schema Information

Table name: vendor_ticket_transaction_payments

id                    :bigint           not null, primary key
amount_cents          :integer
amount_currency       :string(191)      default("THB")
paid_at               :datetime
refund_cents          :integer
refund_reason         :text(65535)
status                :string(191)
created_at            :datetime         not null
updated_at            :datetime         not null
refund_id             :string(191)
ticket_transaction_id :bigint
transaction_id        :string(191)
vendor_id             :integer

Indexes

idx_vttp_ttid  (ticket_transaction_id)

Foreign Keys

fk_rails_...  (ticket_transaction_id => ticket_transactions.id)

Class Method Summary collapse

Methods inherited from ApplicationRecord

sync_carrierwave_url

Class Method Details

.create_payment!(attributes) ⇒ Object



38
39
40
41
42
43
44
# File 'app/models/vendor_ticket_transaction_payment.rb', line 38

def self.create_payment!(attributes)
  if attributes.slice(:ticket_transaction_id, :vendor_id, :transaction_id, :amount_cents, :amount_currency, :status, :paid_at).values.all?(&:present?)
    create!(attributes)
  else
    raise ArgumentError, 'Required attributes are missing for creating a new vendor ticket transaction payment'
  end
end