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