mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
18 lines
453 B
Ruby
18 lines
453 B
Ruby
|
class Subscribe
|
||
|
attr_accessor :payment_method, :user_id
|
||
|
|
||
|
def initialize(payment_method, user_id)
|
||
|
@payment_method = payment_method
|
||
|
@user_id = user_id
|
||
|
end
|
||
|
|
||
|
def pay_and_save(subscription, coupon, invoice)
|
||
|
subscription.user_id = user_id
|
||
|
if payment_method == :local
|
||
|
subscription.save_with_local_payment(invoice, coupon)
|
||
|
elsif payment_method == :stripe
|
||
|
subscription.save_with_payment(invoice, coupon)
|
||
|
end
|
||
|
end
|
||
|
end
|