Class: ForestLiana::StripeController

Inherits:
ApplicationController show all
Defined in:
app/controllers/forest_liana/stripe_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user_from_jwt, #current_user, #serialize_model, #serialize_models

Instance Method Details

#cardsObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/forest_liana/stripe_controller.rb', line 27

def cards
  getter = StripeCardsGetter.new(params,
                                 request.headers['Stripe-Secret-Key'],
                                 request.headers['Stripe-Reference'])
  getter.perform

  render json: serialize_models(getter.records, {
    count: getter.count,
    include: ['customer']
  })
end

#invoicesObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/forest_liana/stripe_controller.rb', line 39

def invoices
  getter = StripeInvoicesGetter.new(params,
                                    request.headers['Stripe-Secret-Key'],
                                    request.headers['Stripe-Reference'])
  getter.perform

  render json: serialize_models(getter.records, {
    count: getter.count,
    include: ['customer']
  })
end

#paymentsObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/forest_liana/stripe_controller.rb', line 4

def payments
  getter = StripePaymentsGetter.new(params,
                                    request.headers['Stripe-Secret-Key'],
                                    request.headers['Stripe-Reference'])
  getter.perform

  render json: serialize_models(getter.records, {
    count: getter.count,
    include: ['customer']
  })
end

#refundObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/forest_liana/stripe_controller.rb', line 16

def refund
  begin
    refunder = StripePaymentRefunder.new(params)
    refunder.perform

    render json: {}
  rescue Stripe::InvalidRequestError => err
    render json: { error: err.message }, status: 400
  end
end