Class: Pay::PaddleClassic::Customer
- Inherits:
-
Customer
show all
- Defined in:
- app/models/pay/paddle_classic/customer.rb
Instance Method Summary
collapse
Methods inherited from Customer
#active?, #customer_name, #deleted?, #has_incomplete_payment?, #on_generic_trial?, #on_trial?, #on_trial_or_subscribed?, #retry_past_due_subscriptions!, #subscribed?, #subscription, #update_payment_method
Instance Method Details
#add_payment_method(token = nil, default: true) ⇒ Object
Paddle does not use payment method tokens. The method signature has it here to have a uniform API with the other payment processors.
43
44
45
|
# File 'app/models/pay/paddle_classic/customer.rb', line 43
def add_payment_method(token = nil, default: true)
Pay::PaddleClassic::PaymentMethod.sync(pay_customer: self)
end
|
#api_record ⇒ Object
9
10
|
# File 'app/models/pay/paddle_classic/customer.rb', line 9
def api_record
end
|
#charge(amount, options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/models/pay/paddle_classic/customer.rb', line 15
def charge(amount, options = {})
return unless subscription.processor_id
raise Pay::Error, "A charge_name is required to create a one-time charge" if options[:charge_name].nil?
response = PaddleClassic.client.charges.create(subscription_id: subscription.processor_id, amount: amount.to_f / 100, charge_name: options[:charge_name])
attributes = {
amount: (response[:amount].to_f * 100).to_i,
paddle_receipt_url: response[:receipt_url],
created_at: Time.zone.parse(response[:payment_date])
}
attributes.merge! Pay::PaddleClassic::PaymentMethod.payment_method_details_for(subscription_id: subscription.processor_id)
charge = charges.find_or_initialize_by(processor_id: response[:invoice_id])
charge.update(attributes)
charge
rescue ::Paddle::Error => e
raise Pay::PaddleClassic::Error, e
end
|
#subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **options) ⇒ Object
37
38
39
|
# File 'app/models/pay/paddle_classic/customer.rb', line 37
def subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **options)
end
|
#update_api_record ⇒ Object
12
13
|
# File 'app/models/pay/paddle_classic/customer.rb', line 12
def update_api_record
end
|