1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/models/payment_schedule_item.rb

27 lines
717 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Represents a due date and the associated amount for a PaymentSchedule
class PaymentScheduleItem < Footprintable
belongs_to :payment_schedule
belongs_to :invoice
has_one :payment_gateway_object, as: :item
2021-04-16 12:25:48 +02:00
after_create :chain_record
def first?
payment_schedule.ordered_items.first == self
end
def payment_intent
2021-04-16 12:25:48 +02:00
return unless payment_gateway_object
2021-04-16 16:03:10 +02:00
# FIXME
key = Setting.get('stripe_secret_key')
stp_invoice = Stripe::Invoice.retrieve(stp_invoice_id, api_key: key)
Stripe::PaymentIntent.retrieve(stp_invoice.payment_intent, api_key: key)
end
def self.columns_out_of_footprint
2021-04-16 12:25:48 +02:00
%w[invoice_id state payment_method client_secret]
end
end