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



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

def stripe_charge
  @order = Effective::Order.find(stripe_charge_params[:effective_order_id])
  @stripe_charge = Effective::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(response) # orders_controller#order_purchased
  else
    flash[:danger] = @stripe_charge.errors.full_messages.join(',')
    render 'checkout'
  end
end