Skip to content

Commit

Permalink
Switch to automatic 3DS confirmation
Browse files Browse the repository at this point in the history
According to Stripe support this is the only correct way to authorize
3D-Secure cards when using the payment request API.
The `confirm` action has been simplified and it now only creates a new
payment intent.
This is only the backend part of the change, JS code will need a more
invasive rework.
  • Loading branch information
spaghetticode committed Apr 21, 2020
1 parent 2d4f6af commit 00f0fb2
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions app/controllers/solidus_stripe/intents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ class IntentsController < Spree::BaseController

def confirm
begin
@intent = begin
if params[:stripe_payment_method_id].present?
create_intent
elsif params[:stripe_payment_intent_id].present?
stripe.confirm_intent(params[:stripe_payment_intent_id], nil)
end
end
@intent = create_payment_intent
rescue Stripe::CardError => e
render json: { error: e.message }, status: 500
return
Expand Down Expand Up @@ -49,13 +43,13 @@ def generate_payment_response
end
end

def create_intent
def create_payment_intent
stripe.create_intent(
(current_order.total * 100).to_i,
params[:stripe_payment_method_id],
description: "Solidus Order ID: #{current_order.number} (pending)",
currency: current_order.currency,
confirmation_method: 'manual',
confirmation_method: 'automatic',
capture_method: 'manual',
confirm: true,
setup_future_usage: 'off_session',
Expand Down

0 comments on commit 00f0fb2

Please sign in to comment.