mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
effe5c7ba9
From now, we no longer retrieve the client_secret directly from the API/list but from a specialized component which ask API/get_item. This highly decrease the laod time needed to fetch API/list
27 lines
760 B
Ruby
27 lines
760 B
Ruby
# 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
|
|
|
|
after_create :chain_record
|
|
|
|
def first?
|
|
payment_schedule.ordered_items.first == self
|
|
end
|
|
|
|
def payment_intent
|
|
return unless payment_gateway_object
|
|
return unless payment_gateway_object.gateway_object.gateway == 'Stripe'
|
|
|
|
stp_invoice = payment_gateway_object.gateway_object.retrieve
|
|
Stripe::PaymentIntent.retrieve(stp_invoice.payment_intent, api_key: Setting.get('stripe_secret_key'))
|
|
end
|
|
|
|
def self.columns_out_of_footprint
|
|
%w[invoice_id state payment_method client_secret]
|
|
end
|
|
end
|