#jackyang_code

1 messages ¡ Page 1 of 1 (latest)

regal forgeBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1297861681094987809

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

compact geyser
#

hi! can you share the full code of the on("confirm") function?

onyx wyvern
#

expressCheckoutElement.on('confirm', async e => {
const { error: submitError } = await this.btnGoogleElements.submit()

    if (submitError) {
      this.global.toast(submitError.message, 5000)
      return
    }

    const { error, paymentMethod } = await this.stripe.createPaymentMethod({
      elements: this.btnGoogleElements
    })

    if (error) {
      this.global.toast(error.message, 5000)
      return
    }

    const res = await $api.creditRent({
      scanUrl: this.params.sno,
      source: 2,
      paymentMethodId: paymentMethod.id,
      rentType: 2
    })
    this.$store.commit('startLoading')

    try {
      const { error: payEroor } = await this.stripe.confirmPayment({
        elements: this.btnGoogleElements,
        clientSecret: JSON.parse(res.data.resp).clientSecret,
        redirect: 'if_required'
      })
      if (payEroor) {
        console.log(payEroor)
        this.global.toast(payEroor.message)
      } else {
        this.showPopup = false
        this.showMask = true
      }
      this.$store.commit('endLoading')
    } catch (e) {
      // console.log(e)
      if (e) {
        this.global.toast(e)
      }
      this.$store.commit('endLoading')
    }
  })
},
compact geyser
#

I see. Unfortunately this is a known bug and the ExpressCheckoutElement doesn't work with using createPaymentMethod

onyx wyvern
#

But I need to use "createPaymentMethod" to get "paymentMethod.id" and go to the background interface to get "clientSecret". How can I solve this problem?

compact geyser
#

you can use ConfirmtionTokens for the same flow(you can send a ConfirmationToken to the backend instead).