#n0rlant1s-avoid-redirect-elements

1 messages ยท Page 1 of 1 (latest)

languid mountain
#

Hello ๐Ÿ‘‹
Can you edit your message to post the code in the thread here please ? It would help us keep the channel tidy ๐Ÿ™‚ Thanks

subtle bramble
#

Yes, one sec

languid mountain
#

super appreciate it thankyou

subtle bramble
#

My code:

const { error } = await stripe.confirmPayment({
      elements,
      confirmParams: {
        // Make sure to change this to your payment completion page
        redirect: "if_required",
        return_url: "http://localhost:3000",
      },
    });
#

The error I'm receiving is:

{
  "error": {
    "code": "parameter_unknown",
    "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
    "message": "Received unknown parameter: redirect",
    "param": "redirect",
    "payment_intent": {
      "id": [redacted],
      "object": "payment_intent",
      "amount": 3000,
      "amount_details": {
        "tip": {
        }
      },
      "automatic_payment_methods": {
        "enabled": true
      },
      "canceled_at": null,
      "cancellation_reason": null,
      "capture_method": "automatic",
      "client_secret": [REDACTED],
      "confirmation_method": "automatic",
      "created": 1657724623,
      "currency": "usd",
      "description": null,
      "last_payment_error": null,
      "livemode": false,
      "next_action": null,
      "payment_method": null,
      "payment_method_types": [
        "card"
      ],
      "processing": null,
      "receipt_email": null,
      "setup_future_usage": null,
      "shipping": null,
      "source": null,
      "status": "requires_payment_method"
    },
    "type": "invalid_request_error"
  }
}
languid mountain
subtle bramble
#

Oh, wow can't believe I didn't try that yet. Thank you! I think it worked.

languid mountain
#

NP! ๐Ÿ™‚ Happy to help

subtle bramble
#

Another quick one for you -- it seems like avoiding redirection causes some additional issues:

#

Adding my code and error above -- in my previous case, it redirected without any issues, but now it's erroring out (error is undefined). Should I change the snippet to have ONLY if error: if {error.type == "card_error}....

languid mountain
#

huh yeah I believe the conditional needs to change

you could add another condition to check if error exists

if (error && error.type === "card_error || ....)

subtle bramble
#

Got it -- just wanted to double check on that -- tysm!!