#maxim-paymentintent-customer

1 messages · Page 1 of 1 (latest)

spare sigilBOT
#

Hello! We'll be with you shortly. 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.

calm forum
#

👋

#

shared-a6af20983956c03384190abd6317e8ef.js:1

   POST https://api.stripe.com/v1/payment_intents/pi_3OC4QZHhLwmbJJWq14G2IhIV/confirm 400 (Bad Request)

(anonymous) @ shared-a6af20983956c03384190abd6317e8ef.js:1
e @ shared-a6af20983956c03384190abd6317e8ef.js:1
l @ shared-a6af20983956c03384190abd6317e8ef.js:1
u @ shared-a6af20983956c03384190abd6317e8ef.js:1
e @ shared-a6af20983956c03384190abd6317e8ef.js:1
confirm @ controller-fabaaa094589d5f860442100c2568363.js:1
(anonymous) @ controller-fabaaa094589d5f860442100c2568363.js:1
n @ shared-a6af20983956c03384190abd6317e8ef.js:1
(anonymous) @ shared-a6af20983956c03384190abd6317e8ef.js:1
(anonymous) @ shared-a6af20983956c03384190abd6317e8ef.js:1
a @ shared-a6af20983956c03384190abd6317e8ef.js:1
i @ shared-a6af20983956c03384190abd6317e8ef.js:1
(anonymous) @ shared-a6af20983956c03384190abd6317e8ef.js:1
(anonymous) @ shared-a6af20983956c03384190abd6317e8ef.js:1
(anonymous) @ controller-fabaaa094589d5f860442100c2568363.js:1
Promise.then (async)
confirmPaymentIntent @ controller-fabaaa094589d5f860442100c2568363.js:1
(anonymous) @ controller-fabaaa094589d5f860442100c2568363.js:1
(anonymous) @ controller-fabaaa094589d5f860442100c2568363.js:1
Promise.then (async)
value @ controller-fabaaa094589d5f860442100c2568363.js:1
handleAction @ controller-fabaaa094589d5f860442100c2568363.js:1
value @ controller-fabaaa094589d5f860442100c2568363.js:1
(anonymous) @ controller-fabaaa094589d5f860442100c2568363.js:1
signin.tsx:67 Er is een verwerkingsfout opgetreden.

distant coyote
#

@calm forum do you have actionable information such as the exact code adn exact request id and exact behaviour?

calm forum
#

Payment intent is right

#
function PaymentForm() {

    const elements = useElements();
    const stripe = useStripe();

    const handleSubmit = async (event: any) => {

        event.preventDefault();
    
        if (!stripe || !elements) {
          // Stripe.js hasn't yet loaded.
          // Make sure to disable form submission until Stripe.js has loaded.
          return;
        }
    
        const result = await stripe.confirmPayment({
          //`Elements` instance that was used to create the Payment Element
          elements,
          confirmParams: {
            return_url: "https://example.com/order/123/complete",
          },
        });
    
        if (result.error) {
          // Show error to your customer (for example, payment details incomplete)
          console.log(result.error.message);
        } else {
          // Your customer will be redirected to your `return_url`. For some payment
          // methods like iDEAL, your customer will be redirected to an intermediate
          // site first to authorize the payment, then redirected to the `return_url`.
        }
    };

    return (
        <form onSubmit={handleSubmit}>
            <PaymentElement />
            <Button variant={"ghost"} className = "bg-blue-500 hover:bg-blue-400" disabled={!stripe}>Pay</Button>
        </form>
    )
}
#

When clicking the pay button it console logs that above

distant coyote
#

Your code cofnirms a PaymentIntent. Something with that confirmation is erroring. As a developer you can look up that request for example in the network tab in Chrome to figure out what's happening and the exact error we are returning
You can also look at the Logs in your Dashboard to find the failed request

calm forum
#

Access-Control-Allow-Credentials:
true
Access-Control-Allow-Methods:
GET,HEAD,PUT,PATCH,POST,DELETE
Access-Control-Allow-Origin:
https://js.stripe.com
Access-Control-Expose-Headers:
Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
Access-Control-Max-Age:
300
Cache-Control:
no-cache, no-store
Content-Length:
1439
Content-Security-Policy:
report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_intents%2F%3Aintent%2Fconfirm; block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'
Content-Type:
application/json
Date:
Mon, 13 Nov 2023 19:04:45 GMT
Idempotency-Key:
12e4a701-b21d-4507-afbf-a9622bcf66b1
Original-Request:
req_HGOTdM30qDoXEW
Request-Id:
req_HGOTdM30qDoXEW
Server:
nginx
Strict-Transport-Security:
max-age=63072000; includeSubDomains; preload
Stripe-Version:
2023-10-16
Timing-Allow-Origin:
https://js.stripe.com
Vary:
Origin
X-Stripe-Routing-Context-Priority-Tier:
api-testmode
:authority:
api.stripe.com
:method:
POST
:path:
/v1/payment_intents/pi_3OC4QZHhLwmbJJWq14G2IhIV/confirm
:scheme:
https
Accept:
application/json
Accept-Encoding:
gzip, deflate, br
Accept-Language:
nl,en;q=0.9,nl-NL;q=0.8,en-US;q=0.7
Content-Length:
947
Content-Type:
application/x-www-form-urlencoded
Origin:
https://js.stripe.com
Referer:
https://js.stripe.com/
Sec-Ch-Ua:
"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"macOS"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-site
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

distant coyote
#

Please don't dump the whole thing

#

Just take a few seconds as a human to read. There should be a clear error message in the response

#

Similarly the API likely returns a clear error message which your code is logging to the JS console

calm forum
#

Ah alr I see

#

A payment intent can only be accessed once

distant coyote
#

not at all

#

PaymentIntents can be accessed any time you want and can be confirmed multiple times. This is not at all the errors

calm forum
#

You cannot confirm this PaymentIntent because it has already succeeded after being previously confirmed.

#

I mean confirmed

distant coyote
#

a PaymentIntent can only be confirmed successfully once. So yes if it succeeded it doesn't make sense to confirm it again. Only if it failed

calm forum
#

alr

#

Is there a way I can connect this payment to a customer id?

distant coyote
#

not sure what that means framed this way.

calm forum
#

const result = await stripe.confirmPayment({
//Elements instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: "https://example.com/order/123/complete",
},
});

How to link it to a customer id

distant coyote
#

that doesn't really make sense.

#

Usually you create a Customer upfront and associate with the PaymentIntent on creation instead. A Customer id doesn't make sense client-side on confirmation

calm forum
#

Yeah but he can pay multiple times

#

And he needs to see the transactions (payments) he made

distant coyote
#

Sure but that's my point. Usually you know your customer already, you track them with for example a login on your app. So whenever they pay for something you should already know who they are and associated their Customer id cus_123 with the PaymentIntent on creation

calm forum
#

Ah oke so the paymentIntent it is

distant coyote
#

maxim-paymentintent-customer

calm forum
#

What is the best way to track when the customer pays

#

Through a webhook or smt?

distant coyote
#

I don't know what "smt" could mean

calm forum
#

something

#

Just what is the best way to track the payment

distant coyote
#

Webhooks are the best way to track payments

calm forum
#

Where can I configure the webhook

distant coyote