Class: VendorPayment

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

Overview

Schema Information

Table name: vendor_payments

id             :bigint           not null, primary key
amount_cents   :integer
currency       :string(191)
paid_at        :datetime
refund_cents   :integer          default(0)
refund_reason  :text(65535)
status         :string(191)
created_at     :datetime         not null
updated_at     :datetime         not null
refund_id      :string(191)
reservation_id :bigint
transaction_id :string(191)
vendor_id      :integer

Indexes

index_vendor_payments_on_reservation_id  (reservation_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
45
# File 'app/models/vendor_payment.rb', line 38

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