#hazem-elkhalil_api

1 messages · Page 1 of 1 (latest)

haughty sirenBOT
hasty geyserBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

haughty sirenBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1242834996595654666

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

native crane
#

  const handleSubmit = async (event) => {
    event.preventDefault();

    if (!stripe || !elements) {
      return;
    }

    const result = await stripe.confirmPayment({
      elements,
      confirmParams: {
        return_url: "http://localhost:3000/bekraftelse",
      },
      redirect: "if_required", // If i dont add this, it will redirect even if the swish payment is canncled
    });

    if (result.error) {
      //The error is not being catched here <------
      return setError(result.error.message!);
    } else {
      console.log(result);
      if (result.paymentIntent.last_payment_error) {
        return setError("Något gick fel med din swish betalning, försök igen!"); // Error here that is not being catched in result.error Error ("partner_generic_decline")
      }
    }
  };```
#

I pasted some code so its easier to understand what is going on

#

here is an object

{
    "id": "pi_3PJFLT0357RGjGIi0UA8NYT2",
    "object": "payment_intent",
    "amount": 1000,
    "amount_details": {
        "tip": {}
    },
    "automatic_payment_methods": null,
    "canceled_at": null,
    "cancellation_reason": null,
    "capture_method": "automatic_async",
    "client_secret": "pi_3PJFLT0357RGjGIi0UA8NYT2_secret_L8D4dY5zWXiRA0f03T3CIm3Ch",
    "confirmation_method": "automatic",
    "created": 1716385003,
    "currency": "sek",
    "description": null,
    "last_payment_error": {
        "code": "payment_method_provider_decline",
        "decline_code": "partner_generic_decline",
        "doc_url": "https://stripe.com/docs/error-codes/payment-method-provider-decline",
        "message": "The customer canceled BankID signing.",
        "payment_method": {
            "id": "pm_1PJFM90357RGjGIiNj4WmSKF",
            "object": "payment_method",
            "allow_redisplay": "unspecified",
            "billing_details": {
                "address": {
                    "city": null,
                    "country": null,
                    "line1": null,
                    "line2": null,
                    "postal_code": null,
                    "state": null
                },
                "email": null,
                "name": null,
                "phone": null
            },
            "created": 1716385045,
            "customer": null,
            "livemode": true,
            "swish": {},
            "type": "swish"
        },
        "type": "card_error"
    },
    "livemode": true,
    "next_action": null,
    "payment_method": null,
    "payment_method_configuration_details": null,
    "payment_method_types": [
        "swish"
    ],
    "processing": null,
    "receipt_email": null,
    "setup_future_usage": null,
    "shipping": null,
    "source": null,
    "status": "requires_payment_method"
}```
#

even the redirect status is succeeded

#

for some reason, really confusing

robust sleet
#

https://docs.stripe.com/payments/swish/accept-a-payment?web-or-mobile=web&payments-ui-type=elements#handle-redirect

After calling confirmPayment, the customers are redirected to Swish to approve or decline the payment. After the customers authorise the payment, they’re redirected to the Payment Intent’s return_url. Stripe adds payment_intent, payment_intent_client_secret, redirect_pm_type, and redirect_status as URL query parameters (along with any existing query parameters in the return_url).

native crane
#

But thats not how it works with cards, which presents the issue that the user is thrown out of the "booking" page and they have to reenter all their details again if the accidantally cancells, is there no way of handling this better ?

#

When a payment fails with cards there is an error in result.error, so they are not redirected

#

Or am i thinking of it in the wrong way ? <.<

robust sleet
native crane
#

ah i understand,

#

okey i wil have to solve this somehow

#

Another question Hanzo, it is a bit irrelevant

#

How would i modify a paymentintents price, in the situation where the user adds a discount, do i have to create a new payment intent or is there a way to edit one

robust sleet
haughty sirenBOT
robust sleet
#

does that help @native crane ?

native crane
#

Yes it does 🙂

#

Thanks a lot hanzo 🙂

#

Last question, how would i remove all unused paymentintents ?

#

those that are uncompleted

vernal garden
native crane
#

thanks 🙂 !