Async/await help, please

Oh, I’ve noticed you do not have return in your payNow() code. It should be

return createToken(...)...

Otherwise, you are not returning a Promise from payNow() method. So await effectively does nothing and just proceeds to next step. wixLocation.to(‘…’) will break the pending payment code by going to a different page.

I hope this helps. Let me know!

P.S. It is really important to mark payments as completed in backend and make PaidMembers collection accessible only to Admin. Otherwise, anyone can insert the record there and become a “paid member”. In the backend code you can do insert with admin rights by specifying suppressAuth parameter.

wixData.insert('PaidMembers', { title: ... }, { suppressAuth: true })