#oguzgbilir-elements

1 messages · Page 1 of 1 (latest)

sour lark
keen sun
#

Sorry, I meant client secret

sour lark
#

Why can't you set the amount of the Payment Intent before creating the Customer and Payment Method?

keen sun
#

Currently what I do with card element is , I am sending a post request and queryy to get amount that the buyer and seller agreed on, and paymentintent is created instantly. I get the client secret as response. However, when I tried to use payment elements, client secret is required by stripe before the checkout component is rendered when there is no agreement or price info. I can use get request as explained by the documents but they used fixed amount. (P.S. I am beginner level, ı might be asking something silly )

sour lark
#

client secret is required by stripe before the checkout component is rendered when there is no agreement or price info
Which method are you using to create the payment element?

keen sun
sour lark
#

Ah, okay. Give me just a few minutes to noodle on this

keen sun
#

I am sending the card element and payment element requirements, you will see the difference:

#

<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>

#

<Elements stripe={stripePromise}>
<CheckoutForm />
</Elements>

#

as you can see, latter (card element) only requires stripePromise while payment element requires option. (which has client secret in it).

#

Problem is I can not get client secret without customer submit the amount.

#

In documents, pre defined price is used in server and client secret is got by a get request.

sour lark
#

So at the point in which you create the options hash, your customer still hasn't fully decided on the payment amount?

keen sun
#

client secret is a result of a payment. Thus, I can not get a client secret without creating a payment intent.

sour lark
#

Ah, so the Client Secret is the result of a Payment Intent, not an actual payment. You can create a Payment Intent without actually charging your cusomer

keen sun
#

Payment intent needs amount. I can not create a payment intent without knowing the amount.

#

In docs they create payment intent with a fixed amount.

sour lark
#

You can update the Payment Intent amount after creation as long as it is still in an open status. Just make sure you pass capture_method: 'manual' so that Stripe does not automatically attempt to charge the Payment Method on creation.

keen sun
#

So am I getting correct ? I will make a fake payment inten in server. by typing some ampunt. Then, I will use get request in app.js and get client secret. I will use that client secret to render checkout page. Then, when customer uses the payment element, ı will create the real payment intent by a post request to server and will get the latest client secret and use it for the payment processing ?