Environment variables & secretsProLesson 11 of 45, about 6 min
- 1
- 2
- 3
- 4
- 5
- 6
- 7
The app: QuickBite
QuickBitelocalhost:3000
Bangkok Garden, Thai25–35 min
Pad thaiRice noodles, tamarind, peanuts. $11.50 each
2
2× Pad thai$23.00
Delivery$2.99
Total$25.99
Deliver to 12 Elm Street
The data behind it
checkout.js runs in the browser
1const API_KEY = "qb_live_DEMO1234";2 3async function placeOrder(order) {4 await fetch("https://api.payments.example/charges", {5 method: "POST",6 headers: { Authorization: `Bearer ${API_KEY}` },7 body: JSON.stringify({ amount: order.total, currency: "usd" }),8 });9}
Downloaded by every visitor View source shows this
const k="";async function p(o){await fetch("https://api.payments.example/charges",{method:"POST",headers:{Authorization:`Bearer ${k}`},body:JSON.stringify({amount:o.total,currency:"usd"})})}
Request the browser will sendPOST payments not sent yet
{
"url": ,
"headers": { "Authorization": },
"body": { "amount": , "currency": }
}
The MagisterOn the left, QuickBite’s checkout, running on your laptop. On the right, the code your agent wrote to charge the card. It sends a secret key to the payments service. Place the order, then tap the key in what the browser sent.
Step 1 of 7Place the order, then find the key
- Place the order
- Tap the key in the request
You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.