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

20 lines
574 B
Ruby

# frozen_string_literal: true
require 'payment/item_builder'
# A link between an object in the local database and another object in the remote payment gateway database
class PaymentGatewayObject < ApplicationRecord
belongs_to :item, polymorphic: true
belongs_to :invoice, foreign_type: 'Invoice', foreign_key: 'item_id'
def gateway_object
item = Payment::ItemBuilder.build(gateway_object_type)
item.retrieve(gateway_object_id)
end
def gateway_object=(object)
self.gateway_object_id = object.id
self.gateway_object_type = object.class
end
end