Class: Pay::PaddleBilling::PaymentMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/pay/paddle_billing/payment_method.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pay_payment_method) ⇒ PaymentMethod

Returns a new instance of PaymentMethod.



27
28
29
# File 'lib/pay/paddle_billing/payment_method.rb', line 27

def initialize(pay_payment_method)
  @pay_payment_method = pay_payment_method
end

Instance Attribute Details

#pay_payment_methodObject (readonly)

Returns the value of attribute pay_payment_method.



4
5
6
# File 'lib/pay/paddle_billing/payment_method.rb', line 4

def pay_payment_method
  @pay_payment_method
end

Class Method Details

.sync(pay_customer:, attributes:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pay/paddle_billing/payment_method.rb', line 8

def self.sync(pay_customer:, attributes:)
  details = attributes.method_details
  attrs = {
    type: details.type.downcase
  }

  case details.type.downcase
  when "card"
    attrs[:brand] = details.card.type
    attrs[:last4] = details.card.last4
    attrs[:exp_month] = details.card.expiry_month
    attrs[:exp_year] = details.card.expiry_year
  end

  payment_method = pay_customer.payment_methods.find_or_initialize_by(processor_id: attributes.stored_payment_method_id)
  payment_method.update!(attrs)
  payment_method
end

Instance Method Details

#detachObject

Remove payment method



36
37
# File 'lib/pay/paddle_billing/payment_method.rb', line 36

def detach
end

#make_default!Object

Sets payment method as default



32
33
# File 'lib/pay/paddle_billing/payment_method.rb', line 32

def make_default!
end