1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/lib/payment/item_builder.rb
Sylvain 87cd41794e WIP: payzen subscription
TODO: retreive the payzen subscription from PayZen::Item
2021-06-02 20:07:53 +02:00

31 lines
644 B
Ruby

# frozen_string_literal: true
require 'pay_zen/item'
require 'stripe/item'
# Payments module
module Payment; end
# Build the corresponding gateway item, according to the provided klass
class Payment::ItemBuilder
attr_reader :instance
def self.build(klass, *ids)
builder = new(klass, *ids)
builder.instance
end
private
def initialize(klass, *ids)
@instance = case klass
when /^PayZen::/
PayZen::Item.new(klass, *ids)
when /^Stripe::/
Stripe::Item.new(klass, *ids)
else
raise TypeError
end
end
end