6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/effective/providers/stripe.rb', line 6
def stripe
raise('stripe provider is not available') unless EffectiveOrders.stripe?
@order = Order.deep.find(params[:id])
@order.current_user = current_user unless admin_checkout?(stripe_params)
@customer = Effective::Customer.for_user(@order.user || current_user)
EffectiveResources.authorize!(self, :update, @order)
payment_intent_id = stripe_params[:payment_intent_id]
if payment_intent_id.blank?
flash[:danger] = 'Unable to process stripe order without payment. please try again.'
return order_not_processed(declined_url: stripe_params[:declined_url])
end
payment = validate_stripe_payment(payment_intent_id)
if payment.blank?
return order_declined(
payment: payment,
provider: 'stripe',
declined_url: stripe_params[:declined_url]
)
end
if payment[:payment_method_id].present?
@customer.update!(payment.slice(:payment_method_id, :active_card))
end
order_purchased(
payment: payment,
provider: 'stripe',
card: payment[:card],
purchased_url: stripe_params[:purchased_url]
)
end
|