3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/services/susply/create_payment.rb', line 3
def self.call(subscription, generated_type)
if subscription.active?
amount = calculate_amount(subscription, generated_type)
payment = Susply::Payment.new do |payment|
payment.owner = subscription.owner
payment.plan = subscription.plan
payment.subscription = subscription
payment.amount = amount
payment.generated_type = generated_type
payment.period_start = subscription.current_period_start
payment.period_end = subscription.current_period_end
payment.status = 'generated'
end
payment.save!
payment
end
end
|