#BidBird®
1 messages · Page 1 of 1 (latest)
Let's start a new one. What's your question?
ahh man
Ok, so on the payment elements page, I have this code:
// Create and mount the Payment Element
const paymentElement = elements.create('payment');
// Stripe injects an iframe into the DOM
card.mount('#card-element');
form.addEventListener('submit', async (event) => { event.preventDefault(); await (async () => { const response = await fetch('/jobs/create/jobcredits/update'); if (response.status === 'requires_payment_method') { const {error} = await elements.fetchUpdates(); } })();
So, we've got an event listener and we're trying to update the PI. However, I don't see how to get the updated amount and other data to update the PI.
public function update($amount){
$intent = \Stripe\PaymentIntent::update( '{{PAYMENT_INTENT_ID}}',
['amount' => $amount] );
echo json_encode(array('status' => $intent->status));}
So that bit of code is what the guid recommends. However, I don't see a way to update the amount.
I believe this may be what you're looking for: https://stripe.com/docs/js/element/other_methods/update?type=card
This merges the new Payment Intent details into the Card Element, so you would call cardElement.update() after you used fetch() to make a server-side call that updated your Payment Intent