Class: StripeCard

Inherits:
StripeModelCallbacks::ApplicationRecord show all
Defined in:
lib/stripe_model_callbacks/models/stripe_card.rb

Instance Attribute Summary

Attributes inherited from StripeModelCallbacks::ApplicationRecord

#stripe_object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StripeModelCallbacks::ApplicationRecord

create_from_stripe!, create_on_stripe!, #destroy_on_stripe, #destroy_on_stripe!, #reload!, #reload_from_stripe!, #update_on_stripe, #update_on_stripe!

Class Method Details

.stripe_classObject



4
5
6
# File 'lib/stripe_model_callbacks/models/stripe_card.rb', line 4

def self.stripe_class
  Stripe::Card
end

Instance Method Details

#assign_from_stripe(object) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stripe_model_callbacks/models/stripe_card.rb', line 8

def assign_from_stripe(object)
  self.stripe_customer_id = object.customer if object.respond_to?(:customer)

  StripeModelCallbacks::AttributesAssignerService.execute!(
    model: self, stripe_model: object,
    attributes: %w[
      id address_city address_country address_line1 address_line1_check
      address_line2 address_state address_zip address_zip_check brand
      country cvc_check dynamic_last4 exp_month exp_year fingerprint
      funding last4 name tokenization_method
    ]
  )
end

#to_stripeObject



22
23
24
# File 'lib/stripe_model_callbacks/models/stripe_card.rb', line 22

def to_stripe
  @to_stripe ||= Stripe::Customer.retrieve(stripe_customer_id).sources.retrieve(stripe_id)
end