Module: Effective::Providers::Stripe

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/effective/providers/stripe.rb

Instance Method Summary collapse

Instance Method Details

#stripe_chargeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/effective/providers/stripe.rb', line 6

def stripe_charge
  @order ||= Effective::Order.find(stripe_charge_params[:effective_order_id])
  @stripe_charge = Effective::Providers::StripeCharge.new(stripe_charge_params)
  @stripe_charge.order = @order

  EffectiveOrders.authorized?(self, :update, @order)

  if @stripe_charge.valid? && (response = process_stripe_charge(@stripe_charge)) != false
    order_purchased(
      details: response,
      provider: (EffectiveOrders.stripe_connect_enabled ? 'stripe_connect' : 'stripe'),
      card: (response['charge']['card']['brand'] rescue nil)
    )
  else
    @page_title = 'Checkout'
    flash.now[:danger] = @stripe_charge.errors.full_messages.to_sentence
    render :checkout_step2
  end
end