Class: Pay::LemonSqueezy::PaymentMethod
Class Method Summary
collapse
Instance Method Summary
collapse
find_by_processor_and_id, pay_processor_for
Class Method Details
.sync(pay_customer:, attributes:) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/models/pay/lemon_squeezy/payment_method.rb', line 4
def self.sync(pay_customer:, attributes:)
return unless pay_customer.subscription
payment_method = pay_customer.default_payment_method || pay_customer.build_default_payment_method
payment_method.processor_id ||= NanoId.generate
attrs = {
payment_method_type: "card",
brand: attributes.card_brand,
last4: attributes.card_last_four
}
payment_method.update!(attrs)
payment_method
end
|
Instance Method Details
#detach ⇒ Object
27
28
|
# File 'app/models/pay/lemon_squeezy/payment_method.rb', line 27
def detach
end
|
#make_default! ⇒ Object
20
21
22
23
24
25
|
# File 'app/models/pay/lemon_squeezy/payment_method.rb', line 20
def make_default!
return if default?
customer.payment_methods.update_all(default: false)
update!(default: true)
end
|