Class: ForestLiana::StripeSourceGetter

Inherits:
StripeBaseGetter show all
Defined in:
app/services/forest_liana/stripe_source_getter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, secret_key, reference) ⇒ StripeSourceGetter

Returns a new instance of StripeSourceGetter.


5
6
7
8
# File 'app/services/forest_liana/stripe_source_getter.rb', line 5

def initialize(params, secret_key, reference)
  @params = params
  Stripe.api_key = ForestLiana.integrations[:stripe][:api_key]
end

Instance Attribute Details

#recordObject

Returns the value of attribute record.


3
4
5
# File 'app/services/forest_liana/stripe_source_getter.rb', line 3

def record
  @record
end

Instance Method Details

#performObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/forest_liana/stripe_source_getter.rb', line 10

def perform
  resource = collection.find(@params[:recordId])
  customer = resource[field]

  @record = ::Stripe::Customer
    .retrieve({ id: customer, expand: ['sources'] })
    .sources.retrieve(@params[:objectId])

  query = {}
  query[field] = @record.customer
  @record.customer = collection.find_by(query)

  @record
end