#theswerd-paymentelement-pm

1 messages · Page 1 of 1 (latest)

craggy nova
#

hello! that is not supported, I know the team has heard that feedback but no timeline on if/when that would be supported

sacred sequoia
#

can payment elements support the charges api with a token?

craggy nova
#

it does not! only supports PaymentIntents and PaymentMethods

#

I think you're trying to do server-side payments right?

#

what is the use-case

sacred sequoia
#

yep

#

its a little bit of a long one

#

I'm doing event ticketing

#

I've designed a system that works using the charges api that:

  1. gets the user information + the amount of tickets they want
  2. puts a hold on that money in their account
  3. sets them as the owner of the tickets
  4. transfers the money to a connect account
    4b. If the transfer fails then they lose ownership of the tickets
#

For this to work I need to be able to not confirm the payout immediately, I need to set the payment Intent amount on my backend after they checkout, and I need to be able to work on my backend so I can manage ticket ownership

sacred sequoia
#

but now I need to get a token i can use for a payment intent on my backend to finish the process

craggy nova
#

but now I need to get a token i can use for a payment intent on my backend to finish the process
you're using a SetupIntent with a PaymentMethod, so that PaymentMethod is what you want to use to confirm a PaymentIntent server-side

#

the "token" is the PaymentMethod

sacred sequoia
#

would stripe?.createPaymentMethod(elements) work?

#

where elements is bound to the PaymentElement

#

?

craggy nova
#

but why do createPaymentMethod()

like don't you already have a PaymentMethod because of

I've taken care of the first two of these by using a setup intent to start

like your SetupIntent is collecting a PaymentMethod, no?

sacred sequoia
#

so i can just send the client secret back to my backend?

#

I think im starting to get this better

#

would I use confirmSetup?

craggy nova
#

let's take a step back

#

can you detail to me, exactly what you've implemented here:

I've taken care of the first two of these by using a setup intent to start

#

what are you doing with a SetupIntent?

sacred sequoia
#

I think I'm actually really getting it now

#

Can setupIntent redirects have form payloads?

hollow sleet
#

Hmm, this is not supported.

sacred sequoia
#

how do i handle if a client secret has already been used, but then a user goes back?

hollow sleet
#

If the Setup is not used, then the client secret is not used. They can go back and use that client serret as it has not been consumed.

sacred sequoia
#

to get the redirect I have to use stripe.confirmSetup

#

and once i do that, when a user goes back to the page, the page doesn't work anymore because it says the setup intent has already been used

hollow sleet
#

In this case, you won't be able to use the client secret as this is already consumed and you'd have a payment method.

#

What are you trying to achieve here?

sacred sequoia
#

currently dealing with stripe.confirmSetup({}), which redirects them to a page that takes in the data and completes the purchase

#

which works

#

however, if a user then presses the back button, and tries to buy more tickets, then it doesn't work

hollow sleet
sacred sequoia
#

i explained earlier in this conversation why i can't use a payment intent

#

i don't know the price ahead of time

scarlet wasp
#

So what's blocking you with SetupIntents?

sacred sequoia
#

that if a user:

  1. enters their card
  2. clicks purchase
  3. we do stripe.confirmSetup with redirectMode always
  4. they get redirected, but then press the back button
  5. they enter their card again,
scarlet wasp
#

When they press the back button they just reload the page right? So you should know who they are and that they did a SetupIntent already and you would redirect them back to another page

sacred sequoia
#

then 5 won't work because it throws a "setup_intent_unexpected_state"

sacred sequoia
#

browsers cache back by default

scarlet wasp
#

Gotcha, so in that case you catch the error and you can handle this accordingly by showing them that they are already confirmed.

sacred sequoia
#

alright

#

thank you

#

wait

#

can I reuse the same secret twice?

#

if they choose to purchase tickets for a second time

scarlet wasp
#

No, the secret is associated to that SetupIntent and it's completed at that point.

#

But you also don't need another SetupIntent if you already have their card details

sacred sequoia
#

so i can reuse the payment method on the setup intent?

scarlet wasp
#

what do you mean "reuse the payment method on the setup intent"

sacred sequoia
#

there is an id of a payment_method on the setup intent

#

can i reuse it more than once?