benschaf / gipfel-tutor

Welcome to our online tutoring platform.
https://gipfel-tutor-768a610dc54f.herokuapp.com/
0 stars 1 forks source link

Do I really still need to handle the standard post request to create my payment model instance? #42

Closed benschaf closed 3 months ago

benschaf commented 4 months ago

This code is from stripe docs and I feel like i sill just have to get all of the payment info on the payment success view via the client secret from stripe - (and create the payment instance there)

    // Submit the payment to Stripe
    const form = document.getElementById('payment-form')

    form.addEventListener('submit', async (event) => {
      event.preventDefault()
      $('#submit').attr('disabled', true)

      const { error } = await stripe.confirmPayment({
        //`Elements` instance that was used to create the Payment Element
        elements,
        confirmParams: {
          return_url: 'http://127.0.0.1:8000/'
        }
      })

      if (error) {
        // This point will only be reached if there is an immediate error when
        // confirming the payment. Show error to your customer (for example, payment
        // details incomplete)
        const messageContainer = document.querySelector('#error-message')
        messageContainer.classList.add('alert', 'alert-danger')
        messageContainer.innerHTML = '<i class="fas fa-exclamation-circle"></i> ' + error.message
        $('#submit').attr('disabled', false)
      } else {
        // Your customer will be redirected to your `return_url`. For some payment
        // methods like iDEAL, your customer will be redirected to an intermediate
        // site first to authorize the payment, then redirected to the `return_url`.
      }
    })
benschaf commented 3 months ago

Seems unnecessary as the way i am using now with an in between payment create view is working fine