#BidBird®

1 messages · Page 1 of 1 (latest)

stoic abyssBOT
slate hemlock
#

Let's start a new one. What's your question?

dark karma
#

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.

slate hemlock
dark karma
#

ok. do I have this right?

At each change when someone updates the stripe element that method is updating the PI?

#

The thing that is confusing is why would we fetch a payment intent, rather than modify the PI that exists when the page loads?