From c2b2b6e8341f7f955587157e2bb9b0399c8095a2 Mon Sep 17 00:00:00 2001 From: marcus06 Date: Thu, 28 May 2026 11:37:55 +0200 Subject: [PATCH] fix: allow redirect next_action so 3ds challenge url surfaces (#17) --- api/handlers/cart.go | 20 +++++++++----------- api/routes/routes.go | 4 ++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/api/handlers/cart.go b/api/handlers/cart.go index ecd4415..c1620e3 100644 --- a/api/handlers/cart.go +++ b/api/handlers/cart.go @@ -392,17 +392,15 @@ func (h *CartHandler) ConvertCart(w http.ResponseWriter, r *http.Request) { // Charge the card. The idempotency key is tied to the order ID so retries // never produce a double charge. piParams := &stripe.PaymentIntentParams{ - Amount: stripe.Int64(int64(total)), - Currency: stripe.String(string(stripe.CurrencyUSD)), - Customer: stripe.String(user.StripeCustomerID), - PaymentMethod: stripe.String(paymentMethodID), - OffSession: stripe.Bool(true), - AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{ - Enabled: stripe.Bool(true), - AllowRedirects: stripe.String("never"), - }, - Confirm: stripe.Bool(true), - Description: stripe.String(fmt.Sprintf("terminal.shop order #%d", order.ID)), + Amount: stripe.Int64(int64(total)), + Currency: stripe.String(string(stripe.CurrencyUSD)), + Customer: stripe.String(user.StripeCustomerID), + PaymentMethod: stripe.String(paymentMethodID), + OffSession: stripe.Bool(true), + PaymentMethodTypes: stripe.StringSlice([]string{"card"}), + ReturnURL: stripe.String(h.appURL + "/post-3ds"), + Confirm: stripe.Bool(true), + Description: stripe.String(fmt.Sprintf("terminal.shop order #%d", order.ID)), Shipping: &stripe.ShippingDetailsParams{ Name: stripe.String(address.Name), Address: &stripe.AddressParams{ diff --git a/api/routes/routes.go b/api/routes/routes.go index 144fd79..670efb8 100644 --- a/api/routes/routes.go +++ b/api/routes/routes.go @@ -61,6 +61,10 @@ func SetupRoutes( w.Header().Set("Content-Type", "text/html") _, _ = w.Write([]byte(`

Card added.

You can close this tab.

`)) }) + r.Get("/post-3ds", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html") + _, _ = w.Write([]byte(`

Authentication complete.

Return to your terminal.

`)) + }) r.Handle("/metrics", middleware.MetricsHandler()) r.Route("/api/v1", func(r chi.Router) {