Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

iOS 12 Error: snap.pay is not allowed to be called in this state #67

Open
rafonzoo opened this issue Feb 13, 2024 · 0 comments
Open

iOS 12 Error: snap.pay is not allowed to be called in this state #67

rafonzoo opened this issue Feb 13, 2024 · 0 comments

Comments

@rafonzoo
Copy link

Hi, thanks for great snapjs payment to ease us doing a payment!
disclaimer: Im using https://app.sandbox.midtrans.com/snap/snap.js, am i put this issue in the correct place? I can't find the repo regarding this snap js to put an issue.

This issue only happened in iOS 12, but it is fine in latest iOS. Here full log:

Error: snap.pay is not allowed to be called in this state. Invalid state transition from PopupInView to PopupInView (anonymous function) — snap.js:232
  ex — 8967.304662da3cf90d03.js:148
  onSuccess — 8967.304662da3cf90d03.js:144
  promiseReactionJob

I call the window snap like:

if (!('snap' in window)) {
  const script = document.createElement('script')
  script.type = 'text/javascript'
  script.dataset.clientKey = process.env.NEXT_PUBLIC_MIDTRANS_CLIENT_KEY ?? '' // prettier-ignore
  script.src = midtrans('/snap/snap.js')
  script.onload = () => onCallback(token, payload)

  document.head.append(script)
  return
}

onCallback(token, payload)

where onCallback is:

window.snap.pay(token, {
  onSuccess: (result: unknown) => {
    const { transaction: trx } = paymentType.shape
    const transaction = trx.parse(result)

    checkout([...detail.payment, { ...payload, transaction }])
  },
})

Help to explain why the error happened, or snap.js not supported in iOS 12 ? Thankyou!
snap.js: https://app.sandbox.midtrans.com/snap/snap.js

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant