What "Instant Delivery" Actually Means
When customers see "instant delivery" on a gift card storefront, they expect to see their code before they close the confirmation page. That means the entire fulfillment pipeline โ payment confirmation, wholesale order placement, code retrieval, and display โ must complete in under 3 seconds.
FoxReload's instant-delivery products fulfill codes synchronously in the API response. There is no queue, no pending state, no waiting period. The moment you POST an order for an in-stock item, the code is in the response body.
The Fulfillment Pipeline
Customer clicks Pay
โ
Payment gateway confirms (Stripe webhook or redirect)
โ
Your backend calls POST /api/v1/orders
โ
FoxReload returns code in response (~200ms)
โ
Code saved to database
โ
Code displayed on success page + emailed (~< 2s total)
Step 1 โ Confirm Payment Before Ordering
Never place a FoxReload order until payment is fully confirmed. Depending on your payment method:
Stripe (Recommended)
Use Payment Intents and listen to the payment_intent.succeeded webhook:
app.post("/webhooks/stripe", express.raw({ type: "application/json" }), async (req, res) => {
const sig = req.headers["stripe-signature"];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
if (event.type === "payment_intent.succeeded") {
const paymentIntent = event.data.object;
await fulfillOrder(paymentIntent.metadata.orderId);
}
res.json({ received: true });
});
Synchronous Checkout (Simpler)
If you use a synchronous payment flow (e.g., redirect-based), check payment status before fulfilling:
app.post("/api/checkout/complete", requireAuth, async (req, res) => {
const { paymentIntentId, productId } = req.body;
// Verify payment status with Stripe
const intent = await stripe.paymentIntents.retrieve(paymentIntentId);
if (intent.status !== "succeeded") {
return res.status(402).json({ error: "Payment not confirmed" });
}
// Fulfill order
const code = await fulfillOrder(productId, paymentIntentId, req.user.email);
res.json({ code, orderId: intent.metadata.orderId });
});
Step 2 โ Place the Wholesale Order
async function fulfillOrder(productId, paymentRef, email) {
const externalOrderId = `order-${paymentRef}`;
// Idempotency: if this runs twice, FoxReload returns the same response
const response = await fetch("https://api.foxreload.com/api/v1/orders", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.FOXRELOAD_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": externalOrderId
},
body: JSON.stringify({
product_id: productId,
quantity: 1,
external_order_id: externalOrderId
})
});
if (!response.ok) {
const err = await response.json();
await handleFulfillmentError(externalOrderId, err);
throw new Error(err.error.code);
}
const order = await response.json();
return order.codes[0].code;
}
Step 3 โ Display the Code Immediately
The success page is the most important page in your checkout flow. Optimize it for clarity:
<!DOCTYPE html>
<html>
<head><title>Your Google Play Gift Card</title></head>
<body>
<div class="success-box">
<h1>Payment successful!</h1>
<p>Your Google Play Gift Card $25 is ready:</p>
<div class="code-box">
<span id="gift-code">{{ code }}</span>
<button onclick="navigator.clipboard.writeText('{{ code }}')">
Copy Code
</button>
</div>
<p class="email-note">We've also sent this code to {{ email }}</p>
<h3>How to redeem:</h3>
<ol>
<li>Open Google Play on your Android device</li>
<li>Tap your profile picture โ Payments & subscriptions โ Redeem gift code</li>
<li>Enter the code above</li>
</ol>
</div>
</body>
</html>
Step 4 โ Send Code via Email (Backup)
Always email the code as a backup. Customers may close the tab before copying it.
const { Resend } = require("resend");
const resend = new Resend(process.env.RESEND_API_KEY);
async function sendCodeEmail(toEmail, code, productName) {
await resend.emails.send({
from: "[email protected]",
to: toEmail,
subject: `Your ${productName} โ Delivery Confirmation`,
html: `
<h2>Your ${productName} is here!</h2>
<p style="font-size:24px; font-family:monospace; background:#f5f5f5; padding:16px;">
${code}
</p>
<p>Keep this email safe. This code can only be used once.</p>
`
});
}
Step 5 โ Handle Fulfillment Failures
Instant delivery can fail if stock runs out between your stock check and order placement. Handle this case:
async function handleFulfillmentError(orderId, error) {
if (error.error.code === "OUT_OF_STOCK") {
// Refund the customer immediately
await issueRefund(orderId);
await notifyCustomer(orderId, "out-of-stock");
// Alert your team
await sendSlackAlert(`Fulfillment failed for ${orderId}: out of stock`);
} else if (error.error.code === "INSUFFICIENT_BALANCE") {
// Critical: top up account immediately
await sendUrgentAlert("FoxReload balance too low โ manual action required");
}
}
Step 6 โ Store Codes Securely
Codes are sensitive. Treat them like passwords:
CREATE TABLE fulfilled_orders (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
product_id VARCHAR(64),
code TEXT NOT NULL, -- consider encrypting at rest
delivered_at TIMESTAMP,
email_sent_at TIMESTAMP,
fox_order_id VARCHAR(64)
);
Allow customers to view their codes in an authenticated account area for 30 days after purchase. After that, consider masking them.
Performance Targets
| Step | Target Time |
|---|---|
| Payment confirmation | < 1 s (Stripe webhook) |
| FoxReload order API | < 300 ms |
| Database write | < 50 ms |
| Success page render | < 200 ms |
| Total from payment | < 2 s |
Delivery Reliability Checklist
- Payment is verified before any FoxReload order is placed
- Idempotency keys prevent duplicate charges on retries
- Success page shows code immediately without page reload
- Email backup sent within 5 seconds
- Fulfillment errors trigger immediate refunds
- Balance alerts prevent INSUFFICIENT_BALANCE failures
- Fulfilled codes stored in database for account history
See Also
- How to set up webhooks for digital code delivery
- How to manage Google Play code inventory
- API for selling Google Play Gift Cards: key integration points
Under 3 seconds from payment to code. Build your fulfillment pipeline with the FoxReload instant delivery API.

