This endpoint example is designed to be used with the checkout button template to enable coupons, shipping address and inventory handling at real-time.
Refer to the docs here for implementing your checkout button template endpoint
- This project is meant to be an example for prototyping only. It's not production ready.
- When you remix (fork) this project on Glitch, your code is public by default, unless you choose to make it private (requires paid subscription to Glitch). Do not use this for any proprietary/private code.
- Env variables are stored & managed by Glitch. Never use the private keys for your production accounts here. Create a temporary private key for testing on Glitch only and replace it with your production key in your own infrastructure.
- Running this endpoint example on Glitch is completely optional and is not required to use WhatsApp Flows. You can run this code in any other environment you prefer.
- Create an account on Glitch to have access to all features mentioned here.
- Remix this project on Glitch.
- Create a private & public key pair for testing, if you haven't already, using the included script
src/keyGenerator.js
. Run the below command in the terminal to generate a key pair, then follow these steps to upload the key pair to your business phone number.
node src/keyGenerator.js {passphrase}
- Click on the file ".env" on the left sidebar, then click on
✏️ Plain text
on top. Do not edit it directly from UI as it will break your key formatting. - Edit it with your private key and passphrase. Make sure a multiline key has the same line breaks like below. Env variables are only visible to the owner of the Glitch project. Use a separate private key for testing only, and not your production key.
PASSPHRASE="my-secret"
PRIVATE_KEY="-----[REPLACE THIS] BEGIN RSA PRIVATE KEY-----
MIIE...
...
...xyz
-----[REPLACE THIS] END RSA PRIVATE KEY-----"
- Use the new Glitch URL as your checkout button template endpoint URL, eg:
https://project-name.glitch.me
. You can find this URL by clicking onShare
on top right, then copy theLive Site
URL. - Edit
src/endpoint.js
with your logic to provide response to actions like applying coupon or shipping etc. - Click on the
Logs
tab at the bottom to view server logs. The logs section also has a button to attach a debugger via Chrome devtools.
WhatsApp Checkout API is MIT licensed, as found in the LICENSE file.