#Scott-payment-element-amount
1 messages ยท Page 1 of 1 (latest)
IntentID, incase it helps: pi_3MUYaGI1YUOItIGB18P5Mbsf
It sounds like you might be updating the Payment Intent after the Payment Element is rendered. Does that sound correct?
That is correct, yea.
Scott-payment-element-amount
This works fine for CC and AU BECS charges, in my experience
So you'll need to make sure you're updating the Payment Element after the Payment Intent is updated, otherwise the Payment Element will assume you want to use the same data that it was initially passed when it was first initialized.
Here's the method to run after the Payment Intent is updated: https://stripe.com/docs/js/elements_object/update_payment_element
Huh, interesting. I don't see any parameters to include amount there - does it query the intent's amount on its own end?
Yep! The Payment Element uses the client secret from the Payment Intent in order to know what amount you're creating the payment for
Ok, awesome! Testing it out now. Thank you!
It looks like I'm still getting the same issue :/ I see the update for the element going through without issue (it even takes the new Business Name supplied which I've gone ahead and passed the new amount into as well e.g. business llc - 12.00 ), but the amount to be charged remains untouched.
Where are you changing the amount? I was under the impression that you were fetching some server-side code that updates the Payment Intent, then reloading the Payment Element
That is exactly what I'm doing.
The user adds/removes items from their cart on their end, we let the back-end server know, which notifies Stripe, then we send back the 200 if it succeeds. After I get the 200, I update the payment element with the code you just gave.
The JS, as a visual aid to the above ^
Hmmm, it's really hard to debug this without being able to see the page in action. Do you have a URL I can use to see the way it's working right now?
Of course, yea. Here you go:
http://sparkpagestest.sparkmembership.com/cart/2/?i=sMK&c=&ocu=
I think you need to add a server-side function that listens for change to the Cart and then updates the Payment Intent only after the cart has been updated. I'm not seeing any network calls after I add something to the cart
Can you send me that Payment Intent ID?
The JS I included is doing this, btw. It creates a DOM observer to update the Payment Intent (the updateTempIntent call) whenever the cart's total changes.
Ahhh, okay I see. Let me submit the form and take a closer look
This seems to be working. Am I missing something? The amount changed just fine: https://dashboard.stripe.com/test/payments/pi_3MUZbzI1YUOItIGB1WeH1jbc
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Right so, did you click to pay with Apple Pay or with a Credit Card?
The issue only appears when attempting to pay with Apple Pay, unfortunately. It works perfectly fine for all other payment methods.
Ahhhhh, right. Okay. Just a moment
Apple Pay isn't showing up for me at all on that page
Does it show up for you?
Are you on an apple device & have a card on file in an Apple Pay wallet?
It shows up for me without issue
Yup. I checked to make sure it was showing up in other places too. I'm on Safari on Mac
๐ I'm hopping in to take a look as well @quiet dirge give me a minute to catch up
Thank you both!
not sure how to screenshot on my iphone, but here is what ive got:
you'll notice, as in the code, the business name includes the amount to charge (12.50, in this case), but the amount itself is off.
quick update - apple pay wasn't showing up for us because you shared the http site, not the https one which is a requirement for apple pay showing up
Sorry about that - here is the correct link:
https://sparkpagestest.sparkmembership.com/cart/2/?i=sMK&c=&ocu=
Are you using paymentElement.update? I believe you need to be using elements.fetchUpdates() instead (see https://stripe.com/docs/js/elements_object/fetch_updates)
I was using paymentElement.update() per two-shoe's recommendation - let me swap it out with a call of elements.fetchUpdates() instead. One minute, please.
The new code is live, but the amount to charge is still not being updated :/ Any ideas?
I see it working fine on my end
I'm on a PC
Huh, it just started working for me too.
What should I do to ensure that the client doesn't get charged for $1.00 instead of the $22.15 that they are supposed to, in this scenario?
If you've updated the Payment Intent I believe it's a guarantee that the amount we'll be charging is the amount set on the PI - the part that hasn't been updated is just the UI. We should still be charging the correct amount
got it - Thank you so much! ๐