testing · 2025-04-07 · 5 min read

Sandbox vs. live mode: the switch that bites on launch day

Test numbers work only with test API keys; real cards only with live keys. Mixing them is the single most common first-launch failure — here is the checklist that prevents it.

Two environments, two sets of keys.
Two environments, two sets of keys. — © Julio Lopez · Pexels

Every provider separates test and live environments by API key — Stripe with sk_test_ / sk_live_ prefixes, PayPal with separate sandbox and live apps, Braintree with separate merchant IDs. The two worlds never meet: a test card against a live key is declined; a real card against a test key is rejected or silently ignored.

Symptoms of a mixed-up environment

  • 'Your card was declined' for every customer on launch morning — test keys in production.
  • Orders marked paid but no money arriving — live front end, test back end.
  • Webhooks never firing — endpoint registered in the wrong mode.
  • Dashboard shows the payment but in the other mode's view.

Pre-launch checklist

  • Swap keys in configuration or secrets, never in code, and make the live key unavailable in CI.
  • Register webhook endpoints in live mode and verify signatures with the live signing secret.
  • Run one real low-value transaction with your own card and refund it.
  • Confirm the publishable key in the browser bundle is the live one — it is easy to ship a cached test build.
  • Keep a staging environment that uses test keys permanently so you can keep using the sandbox numbers.

Stripe's test mode documentation and the PayPal sandbox guide describe each provider's specifics.

Validation on this site is mode-agnostic: it only inspects format. Whether a number is accepted is decided entirely by the gateway and the issuer — see the limits section.
Swap keys in configuration, never in code.
Swap keys in configuration, never in code.

Keywords: sandbox mode, live mode, test API keys, payment go-live checklist, webhooks, Stripe test mode, PayPal sandbox

Frequently asked questions

Why does 4242 4242 4242 4242 get declined on my live site?

Because test numbers only work with test API keys. In live mode the network treats them as non-existent cards.

Can I use my real card to test a live integration?

Yes — one low-value charge followed by a refund is the standard final check before launch.

On this site

External references

Related articles

وضع الاختبار مقابل الوضع الحي: المفتاح الذي يعضّ يوم الإطلاق — النسخة العربية

تعمل أرقام الاختبار مع مفاتيح API الاختبارية فقط؛ والبطاقات الحقيقية مع المفاتيح الحية فقط. والخلط بينهما أشهر فشل عند الإطلاق الأول — إليك القائمة التي تمنعه.

يفصل كل مزوّد بين بيئتي الاختبار والإنتاج بـمفتاح API — Stripe ببادئتي sk_test_ / sk_live_، وPayPal بتطبيقين منفصلين، وBraintree بمعرّفي تاجر منفصلين. العالمان لا يلتقيان أبدًا: بطاقة اختبار مع مفتاح حي تُرفض؛ وبطاقة حقيقية مع مفتاح اختبار تُرفض أو تُتجاهل بصمت.

أعراض البيئة المختلطة

  • «تم رفض بطاقتك» لكل عميل صباح الإطلاق — مفاتيح اختبار في الإنتاج.
  • طلبات معلَّمة مدفوعة دون وصول أموال — واجهة حية وخلفية اختبار.
  • webhooks لا تُطلق أبدًا — نقطة النهاية مسجّلة في الوضع الخطأ.
  • لوحة التحكم تُظهر الدفعة لكن في عرض الوضع الآخر.

قائمة تحقق قبل الإطلاق

  • بدّل المفاتيح في الإعدادات أو الأسرار لا في الكود، واجعل المفتاح الحي غير متاح في CI.
  • سجّل نقاط webhook في الوضع الحي وتحقق من التوقيعات بسر التوقيع الحي.
  • نفّذ معاملة حقيقية واحدة بقيمة صغيرة ببطاقتك وأعد المبلغ.
  • تأكد أن المفتاح القابل للنشر في حزمة المتصفح هو الحي — من السهل شحن بناء اختبار مخزّن.
  • احتفظ ببيئة staging تستخدم مفاتيح الاختبار دائمًا لتواصل استخدام أرقام الاختبار.

توثيق وضع الاختبار في Stripe ودليل PayPal التجريبي يصفان خصوصيات كل مزوّد.

التحقق في هذا الموقع محايد تجاه الوضع: يفحص الصيغة فقط. وقبول الرقم تقرّره البوابة والمُصدِر كليًا — انظر قسم الحدود.

أسئلة شائعة

لماذا يُرفض 4242 4242 4242 4242 على موقعي الحي؟

لأن أرقام الاختبار تعمل مع مفاتيح API الاختبارية فقط. في الوضع الحي تعاملها الشبكة كبطاقات غير موجودة.

هل يمكنني استخدام بطاقتي الحقيقية لاختبار التكامل الحي؟

نعم — رسم واحد بقيمة صغيرة يتبعه استرداد هو الفحص النهائي المعتاد قبل الإطلاق.

Educational content — not legal or financial advice. Open the interactive Check Digit Lab →