Module: Pay::Paddle::Billable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/pay/paddle/billable.rb
Instance Method Summary collapse
- #create_paddle_charge(amount, options = {}) ⇒ Object
- #create_paddle_subscription(name, plan, options = {}) ⇒ Object
- #paddle_customer ⇒ Object
- #paddle_invoice!(options = {}) ⇒ Object
- #paddle_subscription(subscription_id, options = {}) ⇒ Object
- #paddle_trial_end_date(subscription) ⇒ Object
- #paddle_upcoming_invoice ⇒ Object
- #update_paddle_card(token) ⇒ Object
- #update_paddle_email! ⇒ Object
Instance Method Details
#create_paddle_charge(amount, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pay/paddle/billable.rb', line 14 def create_paddle_charge(amount, = {}) return unless subscription.processor_id raise Pay::Error, "A charge_name is required to create a one-time charge" if [:charge_name].nil? response = PaddlePay::Subscription::Charge.create(subscription.processor_id, amount.to_f / 100, [:charge_name], ) charge = charges.find_or_initialize_by( processor: :paddle, processor_id: response[:invoice_id] ) charge.update( amount: Integer(response[:amount].to_f * 100), card_type: subscription.processor_subscription.payment_information[:payment_method], paddle_receipt_url: response[:receipt_url], created_at: DateTime.parse(response[:payment_date]) ) charge rescue ::PaddlePay::PaddlePayError => e raise Error, e. end |
#create_paddle_subscription(name, plan, options = {}) ⇒ Object
33 34 35 |
# File 'lib/pay/paddle/billable.rb', line 33 def create_paddle_subscription(name, plan, = {}) # pass end |
#paddle_customer ⇒ Object
10 11 12 |
# File 'lib/pay/paddle/billable.rb', line 10 def paddle_customer # pass end |
#paddle_invoice!(options = {}) ⇒ Object
57 58 59 |
# File 'lib/pay/paddle/billable.rb', line 57 def paddle_invoice!( = {}) # pass end |
#paddle_subscription(subscription_id, options = {}) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/pay/paddle/billable.rb', line 50 def paddle_subscription(subscription_id, = {}) hash = PaddlePay::Subscription::User.list({subscription_id: subscription_id}, ).try(:first) OpenStruct.new(hash) rescue ::PaddlePay::PaddlePayError => e raise Error, e. end |
#paddle_trial_end_date(subscription) ⇒ Object
45 46 47 48 |
# File 'lib/pay/paddle/billable.rb', line 45 def paddle_trial_end_date(subscription) return unless subscription.state == "trialing" DateTime.parse(subscription.next_payment[:date]).end_of_day end |
#paddle_upcoming_invoice ⇒ Object
61 62 63 |
# File 'lib/pay/paddle/billable.rb', line 61 def paddle_upcoming_invoice # pass end |
#update_paddle_card(token) ⇒ Object
37 38 39 |
# File 'lib/pay/paddle/billable.rb', line 37 def update_paddle_card(token) # pass end |
#update_paddle_email! ⇒ Object
41 42 43 |
# File 'lib/pay/paddle/billable.rb', line 41 def update_paddle_email! # pass end |