I’m building a payment system for some ebooks with Reactjs on the frontend, Firebase as hosting and database and cloud functions at the backend side. Customers don’t need an account to buy ebooks so they are not logged in or getting an account.
At this point I’ve got a form for their firstname, lastname and email and a hidden field with the ebook they want to buy. This is the first step. After submitting the form I’m checking if everything is valid. When everything is valid I want to send the data to the server. I want to check the data there as well (you never know if somebody is changing the fronted code). When the server check is done and valid, a push to the database has to be made. At this point, a new entry is made with a unique key. All the time, the user is on a redirected page (something like www.mydomain.com/addNewCustomerInformation
(to send information to my server) (Note: the url is a redirect from https://us-central1-<projectname>.cloudfunctions.net/addNewCustomerInformation
)) with a loading icon.
Now that the basic information is known and put in the database another redirect takes place to send the user to a confirmation page. First the user has to check if the information is correct, secondly he has to choose a payment option (I’m using Stripe). The options are Alipay, iDeal, bancontact, bitcoin and credit card. So I’m having a more complex system than examples that are only using credit card. Because there are some examples for credit cards, I will go on for iDeal.
When the user has checked his information (It’s not with a confirm button. You can edit your information if there was something wrong.) and clicked on the iDeal button a Stripe source needs to be made and with a redirect the user will be guided through the iDeal steps. The payment part already works so I will skip this. After the payment, the user gets a mail with a 72h link to download the ordered eBook. This is for security sharing reasons. After 72h the link needs to expire (how can I do this?).
So here are my questions:
1) The part were I redirect the user to another url so I can do a post to my server (webhooks), let them wait with a loading icon and do another redirect when I’m getting data back from the server looks very unclean to me. What is a better way to do this?
2) How can I make the url expire after 72h? (so, how can I make the unique id that’s in the database expire after 72h)