Class: Profitable::Processors::PaddleClassicProcessor

Inherits:
Base
  • Object
show all
Defined in:
lib/profitable/processors/paddle_classic_processor.rb

Instance Attribute Summary

Attributes inherited from Base

#subscription

Instance Method Summary collapse

Methods inherited from Base

#initialize, subscription_data

Constructor Details

This class inherits a constructor from Profitable::Processors::Base

Instance Method Details

#calculate_mrrObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/profitable/processors/paddle_classic_processor.rb', line 4

def calculate_mrr
  data = subscription_data
  return 0 if data.nil?

  amount = data['recurring_price']
  return 0 if amount.nil?

  # Paddle Classic payloads may expose string amounts; coerce before quantity math.
  quantity = subscription.quantity || 1
  interval = data['recurring_interval']
  interval_count = 1 # Paddle Classic doesn't have interval_count

  normalize_to_monthly(amount.to_f * quantity, interval, interval_count)
end