#Typedef-react

1 messages · Page 1 of 1 (latest)

warped pond
#

The attach API is a backend method, you won't have it frontend.

next stump
#

ahh is there a way to attach customer id in frontend

warped pond
#

I think when you create a PaymentIntent backend, it's the timing to include the Customer Id

next stump
#

i can just do customer: customerId ?

warped pond
#

before returning PaymentIntent's secret to client

next stump
#

in payment intent backend

warped pond
#

yeah

next stump
#
const paymentIntent = await stripe.paymentIntents.create({
            amount,
            currency: 'usd',
            metadata: {
                integration_check: 'accept_a_payment'
            },
            receipt_email: email,
            customer: curUser.customerId
        })

I did this on backend

#

payment method on front end is still null

warped pond
#

Where do you see it's null?

next stump
#

customer

warped pond
#

After confirming call?

next stump
#

ye I do a post request first then create payment method on frontend

warped pond
#

sorry, in a MTG and will be back in 10-15 mins

next stump
warped pond
#

🔙

#

Okie quick question: What do you do after createPaymentMethod? Will you use it to confirm a PaymentIntent?

#

At the timing of creating PaymentMethod, it's true that you still can't attach it to a Customer yet. But when you use it to confirm a PaymentIntent, which is tighted to a Customer, they will all connect: the PaymentIntent, the Customer, and the PaymentMethod

next stump
warped pond
#

yeah!

next stump
#

looks like it created a new "guest" customer

#

instead of using the existing one

warped pond
#

Did you pass Customer Id on PaymentIntent creation?

next stump
#

yep

#

i checked if it was null also

#

it is succesfully settings the customer in paymentintents tho

#

just logged it

#

oh i think it worked now

#

is there a way to delete guest customers

warped pond
#

Did it... just work?

next stump
#

i had customer key the whole time in paymentintent

warped pond
#

I think you would also want setup_future_usage

#

When both setup_future_usage and a customer are provided on a PaymentIntent, the payment details are automatically saved to the customer once the payment is confirmed. You can also supply this parameter when creating the PaymentIntent on your server.

next stump
#

sounds good thanks. is there a way to delete

#

guest customers

warped pond
#

Yeah I am looking for that

#

1 min

next stump
#

i wonder why it created guest account but it knows that it is related to a customer haha

warped pond
#

Sorry I think you can't delete guest customers. Please just ignore them

#

But I think if you specify both customer and setup_future_usage, it shouldn't create a Guest customer in the first place. LMK if you see diffirent

next stump
#

sounds good thanks!

warped pond
#

I am stepping down for the day. If you need more help, feel free to open another thread!