#ptman-upe-holds

1 messages ยท Page 1 of 1 (latest)

opal rockBOT
prisma aurora
#

ptman-upe-holds

crisp vale
#

that just mentions the card element

#

I'd hope for something that shows createPaymentMethod using the payment element

prisma aurora
crisp vale
prisma aurora
crisp vale
#

If I'm making a hold, I need to create a payment method

#

createPaymentMethod() wants card, the card element, not payment, the payment element

prisma aurora
#

Correct, createPaymentMethod does not support the Payment Element, because it is an older method that is typically not needed anymore.

The field that instructs us to only authorize the payment (not fully process it) is on the Payment Intent object, not on the Payment Method object, so you don't need to have already created a Payment Method. You'll notice in the first code snippet, in the guide on holds, that no Payment Method is provided while creating the Payment Intent:
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements

Securely accept payments online.

crisp vale
#

I'm creating holds, not accepting payments directly

prisma aurora
#

Are you going to process the payment eventually, or are you just creating holds?

crisp vale
#

I'm going to process it once service has been rendered

prisma aurora
#

Creating a Payment Method via the Payment Element requires use of a Setup Intent, which seems unnecessary for your flow.

I think the most straight-forward approach is for you to follow the Payment Element guide, but set capture_method to manual when creating the Payment Intent. Once the Payment Intent goes to the requires_capture state and you're ready to capture it, then use this function make the request to capture it:
https://stripe.com/docs/api/payment_intents/capture

crisp vale
#

right

#

I know how to capture

#

I want to move the payment intent from requires_payment_method to requires_capture

#

using the payment element style

prisma aurora
#

That's the confirmation step, you would use confirmPayment

crisp vale
#

instead of the older card element style, which we're trying to move away from

prisma aurora
crisp vale
#

so the correct paymentIntent is used based on clientSecret instead of separately attaching a payment method using createPaymentMethod?

prisma aurora
#

Are you using already created Payment Methods, or are you wanting to create a Payment Method as part of the flow?

The Payment Element creates a Payment Method, from the information that your customer has entered into it, and attaches it to the related Payment Intent as part of the confirmPayment step.

crisp vale
#

thank you

#

now I can indeed do the simple hold-confirm-capture using the payment element

#

I wonder why the code was so convoluted using the card element

#

maybe it will get there as I re-add handling of saved card and connected account

prisma aurora
#

All of those topics do add some complexity, so it's very likely your code will need to grow as you incorporate them.

crisp vale
#

if I use setup_future_use with connect, does it get stored to the main account or the connected account?

#

it's also been a couple of years since I worked with this, and stripe has just worked so that I haven't needed to touch it

prisma aurora
#

Ah gotcha, things have a changed a fair bit just this year, so I suspect you'll see some pretty drastic changes if you haven't touched it for several years.

Where the objects get created is dependent on the charge structure that you're using. If you're using Destination Charges (setting transfer_data.destination) then the objects will all be created on your Platform account. If you're using Direct Charges (using the Stripe-Account header/param), then all of the objects will be stored on the Connected Account.

crisp vale
#

direct charges

#

and we did manage to store the payment details on the platform account previously, but it took some work

solar vigil
#

Hello ๐Ÿ‘‹
Taking over as toby needs to step away soon

#

direct charges
Gotcha. So in that case the PaymentMethod would be stored on the connected account.

crisp vale
#

and in order to store the payment method on the platform I need to do that first and then clone the paymentmethod to the connected account and and then create the paymentintent

#

or so I think it was done

solar vigil
#

Yup exactly.