Class: Profitable::Processors::PaddleBillingProcessor

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

Instance Attribute Summary

Attributes inherited from Base

#subscription

Instance Method Summary collapse

Methods inherited from Base

#initialize

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
# File 'lib/profitable/processors/paddle_billing_processor.rb', line 4

def calculate_mrr
  price_data = subscription.data['items']&.first&.dig('price')
  return 0 if price_data.nil?

  amount = price_data['unit_price']['amount']
  quantity = subscription.quantity || 1
  interval = price_data['billing_cycle']['interval']
  interval_count = price_data['billing_cycle']['frequency']

  normalize_to_monthly(amount * quantity, interval, interval_count)
end