Sha256: af1e5feb05216ccae9d3fc2e23f5c53290f5b95e5590f829cf94ed2a22404f87

Contents?: true

Size: 797 Bytes

Versions: 78

Compression:

Stored size: 797 Bytes

Contents

class Ish::Payment
  include Mongoid::Document
  include Mongoid::Timestamps

  belongs_to :invoice, class_name: 'Ish::Invoice', optional: true
  belongs_to :profile, class_name: 'Ish::UserProfile'
  belongs_to :item,    polymorphic: true

  field :amount, :type => Integer # in cents
  field :charge, :type => Hash
  field :email,  :type => String

  field :client_secret
  field :payment_intent_id

  STATUS_CONFIRMED = 'confirmed'
  STATUS_PENDING = 'pending'
  STATUSES = %w| active pending |
  field :status, type: Symbol, default: STATUS_PENDING
  scope :confirmed, ->{ where( status: STATUS_CONFIRMED ) }

  after_create :compute_paid_invoice_amount
  def compute_paid_invoice_amount
    self.invoice&.update_attributes({ paid_amount: self.invoice.paid_amount + self.amount })
  end

end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
ish_models-3.0.0.1 lib/ish/payment.rb
ish_models-0.0.33.304 lib/ish/payment.rb
ish_models-0.0.33.303 lib/ish/payment.rb
ish_models-0.0.33.302 lib/ish/payment.rb
ish_models-0.0.33.301 lib/ish/payment.rb
ish_models-0.0.33.300 lib/ish/payment.rb
ish_models-0.0.33.299 lib/ish/payment.rb
ish_models-0.0.33.298 lib/ish/payment.rb
ish_models-0.0.33.297 lib/ish/payment.rb
ish_models-0.0.33.296 lib/ish/payment.rb
ish_models-0.0.33.295 lib/ish/payment.rb
ish_models-0.0.33.294 lib/ish/payment.rb
ish_models-0.0.33.293 lib/ish/payment.rb
ish_models-0.0.33.292 lib/ish/payment.rb
ish_models-0.0.33.291 lib/ish/payment.rb
ish_models-0.0.33.287 lib/ish/payment.rb
ish_models-0.0.33.286 lib/ish/payment.rb
ish_models-0.0.33.285 lib/ish/payment.rb
ish_models-0.0.33.284 lib/ish/payment.rb
ish_models-0.0.33.283 lib/ish/payment.rb