Unverified Commit acbbf14a authored by Jonathan Steele's avatar Jonathan Steele Committed by GitHub

example: Add `elements.update()` to ensure latest payment amount is reflected (#54848)

### What?
In the Payment Element demo, call
[`elements.update()`](https://stripe.com/docs/js/elements_object/update)
when the payment amount value is updated via slider. This ensures
wallets (Apple Pay, Google Pay) display the correct payment amount.

---------
Co-authored-by: 's avatarMichael Novotny <manovotny@gmail.com>
parent 1fc4b22d
......@@ -61,12 +61,15 @@ function CheckoutForm(): JSX.Element {
}
}
const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (e) =>
const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
setInput({
...input,
[e.currentTarget.name]: e.currentTarget.value,
})
elements?.update({ amount: input.customDonation * 100 })
}
const handleSubmit: React.FormEventHandler<HTMLFormElement> = async (e) => {
try {
e.preventDefault()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment