Online ordering on the cheap.
Our neighbours have a Burger restaurant (it’s called Burgerlijk, delicious premium burgers!). With the pandemic creating a lot of uncertainty (The government closed them for several months in 2020, and in 2021 the rules are very strict). That’s what go them thinking: We should try out selling online!
That’s where I come in (If you don’t know me: I’m Matthias Nys, a passionate Software developer, mainly working on big backend projects). They asked: Can you setup a small form for selling our “DIY Burger boxes” that we will deliver to people in some neighbourhoods and cities at certain point in time.
Tally.so
Now I could setup a whole webshop that arranges everything, But that seemed like overkill for a PoC. So I suggested we could use a tool called Tally.so, it’s locally built (We live in Belgium) and very versatile. It also has a lof of integrations
We started off by building a form that made sure we could get the orders in.
Some business rules:
- Grownup box: 17euro
- Kids 10euro
- No orders under 30euro (should block)
- Only delivering at some postal-codes at certain time-slot.
An afternoon of fiddling and we came up with this:
After completing the form you get a summary that looks like this:
This processed the form and we could get the answers in the dashboard:
Google Sheets
Great, seems like a succes! But Tally itself has some great integrations:
So we just enabled the Google Sheets and we could process them in the trusted environment of a spreadsheet
That’s a lot easier!
Paying (Stripe)
Tally.so also has a feature to make sure people can pay on the form. Details can be found here: https://blog.tally.so/collecting-payments-with-tally/.
We started implementing this into the form:
- Created a Stripe Account
- Coupled it to the little widget
- Started testing it
Unfortunately we had stop using it. It only supports Credit Cards and the majority of Belgian online payments goes through Bancontact.
What a pity… We really wanted to enabled direct payments, that would make sure we have less problems while delivering our boxes!
Paying (Mollie)
After some digging I found out that we could use a “payment-link”, a service from Mollie to create our payments.
The concept is rather easy: Just do an api call to Mollie for a certain payment with certain description. Hand over the link to the other party, let them pay and voila you are sure you have your money.
Webhooks (Tally)
So, how do we create a payment-link at Mollie when they submit their Tally.so form?
Fortunately Tally.so has support for Webhooks. Every time a form is submitted, the webhook is called with relevant information:
POST
{
"eventId":"c041c4b4-ecdf-4a6a-9ea7-7564c9698b52",
"createdAt":"2021-12-24T08:38:29.699Z",
"data":{
"responseId":"4cdf0680-4db7-8ee9-001a5fcddd1c",
"submissionId":"wgaBMfffffm",
"respondentId":"wzOEdddd1n",
"formId":"nananan",
"formName":"blablabla",
"createdAt":"2021-11-03T07:08:26.404Z",
"fields":[
{
"key":"question_3qayg7_85a8144f-975d-4e71-b793-8461f356c712",
"label":"PrijsVolwassen",
"type":"CALCULATED_FIELDS",
"value":16104
},
{
"key":"question_mBKv6N_3bab1b60-0679-4092-bb67-5de75ab4accf",
"label":"PrijsKinderen",
"type":"CALCULATED_FIELDS",
"value":6647
},
{
"key":"question_mKeXO7_e7cc0d4c-ec9a-4c28-bca2-7fc7f93e5648",
"label":"Totaal",
"type":"CALCULATED_FIELDS",
"value":24315
},
{
"key":"question_nPDoO0",
"label":"Aantal volwassenen (€ 17,00 / persoon)",
"type":"INPUT_NUMBER",
"value":4
},
{
"key":"question_3jbKQ9",
"label":"Aantal kinderen (€ 10,00 / persoon)",
"type":"INPUT_NUMBER",
"value":2
},
{
"key":"question_nWr4zQ",
"label":"Wanneer leveren?",
"type":"DROPDOWN",
"value":"ce26c9a0-6cec-41f8-bbc3-eace33d924db",
"options":[
{
"id":"ce26c9a0-6cec-41f8-bbc3-eace33d924db",
"text":"8540 - Deerlijk ( 25/12/2021 - voormiddag)"
},
{
"id":"de40da9d-8fba-4155-9124-2d6039bdf8c9",
"text":"8531 - Bavikhove (25/12/2021 - voormiddag)"
},
{
"id":"827b86fb-125a-472c-814a-03b87fb87d78",
"text":"8530 - Harelbeke (25/12/2021 - voormiddag)"
},
{
"id":"19e243ae-99d2-4256-a2cd-99f4445c82b3",
"text":"8500 - Kortrijk (26/12/2021 - namiddag)"
},
{
"id":"f06d8445-6202-4e55-bc3c-e1a466dadfaf",
"text":""
}
]
},
{
"key":"question_w4BDZA",
"label":"Details",
"type":"INPUT_TEXT",
"value":"Pataca"
},
{
"key":"question_3jbqKJ",
"label":"Naam",
"type":"INPUT_TEXT",
"value":"Row"
},
{
"key":"question_w2Bg2D",
"label":"Email",
"type":"INPUT_EMAIL",
"value":"some@email.com"
},
{
"key":"question_n9XeQ4",
"label":"GSM nummer",
"type":"INPUT_PHONE_NUMBER",
"value":"1-774-541-3913 x438"
},
{
"key":"question_3xjLGv",
"label":"Adres",
"type":"INPUT_TEXT",
"value":"RSS"
}
]
}
}
Serverless (Lambda AWS)
We use this for the input on the script that will create a payment-link and send the email.
The script is running on AWS Lambda (using Serverless).
To get started: Just create an account on app.serverless.com and click on create. Choose node HTTP API
and you can just follow the instructions on setting up the development environment on your local machine!
Lambda Code
After setting up the serverless environment we can continue on the code itself.
The code has to do 3 things:
- Parse the webhook event from Tally (get Amount, name, submissionId)
- Create a payment-link in Mollie
- Send an e-mail using sendgrid (or any other provider)
So to get started with the Lambda we need to declare a function in the serverless.yaml
file.
org: some-org
app: some-app
service: some-serviceframeworkVersion: '2'provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: '20201221'functions:
hello:
handler: handler.hello
events:
- httpApi:
path: /
method: get
webhook:
handler: handler.webhook
events:
- httpApi:
path: /webhook
method: post
After that we can extend the handler.js with the following code (inline comments for more info)
Now deploy it using sls deploy
in your terminal:
burgerlijk-box-send-mollie sls deployServerless: Using provider credentials, configured via dashboard: https://app.serverless.com/....Serverless: Packaging service...Serverless: Excluding development dependencies...Serverless: Ensuring that deployment bucket existsServerless: Uploading CloudFormation file to S3...Serverless: Uploading artifacts...Serverless: Uploading service mollie.zip file to S3 (385.8 kB)...Serverless: Validating template...Serverless: Updating Stack...Serverless: Checking Stack update progress........................Serverless: Stack update finished...Service Informationservice: some-servicestage: devregion: us-east-1stack: some-service-devresources: 29api keys:Noneendpoints:GET - https://xxxxxxx.amazonaws.com/POST - https://xxxxxxxx.amazonaws.com/webhookfunctions:hello: test-hellowebhook: test-webhooklayers:NoneServerless: Removing old service artifacts from S3...Serverless: Publishing service to the Serverless Dashboard...Serverless: Successfully published your service to the Serverless Dashboard: https://app.serverless.com/...
In the above you can see the url for your webhook: https://xxxxx.amazonaws.com/webhook
-> add this to Tally webhook and click TEST. You should be able to see it in your serverless dashboard.
When you now submit a post an email will be sent out to the email address provided (be sure to setup a proper template, not part of this tutorial).
Google sheets (part 2)
Now we have all the data in Mollie, but we should also update the status in Google sheets as well to know if a certain order was paid for or not!
Google App Scripts to the rescue. Open the Spreadsheet that is linked to Tally.so. Click on Extensions
and then Apps Script
.
After that I added a script that fetches all the orders from Mollie and tries to match them up with the lines in the sheet itself:
On top of the spreadsheet there is now a button called “Mollie” and when you tap on it you get the option to “Update Payments”. That will populate the orders and the status of the payment.
With some google sheet magic and formulas we came out to this:
Take aways
- Tally.so is a great tool!
- Mollie is very easy to use api.
- Google sheets remains very flexible (I’m a huge fan, see other posts as well!)
- Lambda is very inexpensive solution to glue everything together!
- The whole PoC is running for free, except for mollie transaction costs.
This blog post turned out longer than intended, but I felt like writing it down. I created this order form in 2 evenings, so the code might not be perfect at all! The only thing that mattered was getting a form up and running and some automation so we could launch this very quickly and start testing if there is animo enough for more and then build a mature solution.
Want more?
If you need some advice on integrations between any 2 systems. I can provide you professional advice and integrations (Mobile, Backend systems, Websites, databases,…). More information can be found on b-nys.com. Feel free to follow me on Twitter and or LinkedIn.
If you liked this article, please share it with your network!
Matthias,