At launch, the code barely changes; what changes is the surrounding configuration, data, and rules—and they usually live in the customer's account, not in your code repository.

Key takeaways

  • A fully green sandbox only proves the code is correct; production is a different account that needs to be configured from scratch.
  • Common failure points: ID mismatches when recreating objects, unregistered production webhooks, API version mismatches, and transfer limits and approval gates that never appear in the sandbox.
  • Turn the provider's launch documentation into a runnable preflight script, with an assigned owner for every item.

Stripe's launch documentation says that switching between sandbox and production mode is "basically just changing your API keys." As far as code goes, that's true. And that's exactly why it's a trap: the code doesn't change, but everything around it does.

Stripe designed production and the sandbox to behave identically, so all the differences pile up in the surrounding configuration. For a Forward Deployed Engineer (FDE), that's bad news. This configuration usually lives in the customer's account, set up by someone clicking through a UI, with not a single line visible in your code repository.

When you integrate a customer's system with a payments API, a bank, or any third-party service, passing every sandbox test does not mean production is fine. What really matters is the ability to see what the sandbox hides, then write it into a check script and an owned task list to be completed before launch day.

The sandbox is a different account, not a copy

Braintree puts it bluntly: sandbox and production accounts have "no association whatsoever." Transaction processing settings and billing settings do not carry over. Cross River is even more direct: the sandbox is a simulated environment that behaves differently from the real system; production involves real money, real cards, and transfer limits.

So the safe assumption is: treat production as a brand-new customer that needs to be configured from zero. To leave nothing out, break the differences into five layers and check them one by one.

The first layer is identity and addresses. With Stripe, you just swap the keys. With GoCardless, you need to change the base URL from the sandbox host to the production host, or modify the environment variable in the client library.

GoCardless production access tokens are shown only once, at creation. If the person who created it is the customer's accountant and casually pastes it into a chat window, you have a security incident on your hands before launch.

The second layer is objects. According to Stripe, plans, coupons, and products created in the sandbox cannot be used in production mode, to keep test data out of production. You must recreate them with the same IDs—matching names are not enough. Whatever ID the code references, production must contain exactly that ID.

The third layer is events. Production webhooks must be registered separately. GoCardless requires you to add the endpoint in the production account, following the same steps as in the sandbox. Stripe warns that events may arrive late or arrive twice, and your code must not assume they arrive in order.

The API version determines the structure of requests and webhook payloads, and payloads follow the account's version by default. So pin the version and keep both sides consistent.

The fourth layer is rules. In Cross River's production environment, transfer limits based on frequency or amount are configured per project and may reject calls the sandbox never blocked. GoCardless adds one more gate the sandbox doesn't have: custom payment pages must pass a compliance review before going live.

The fifth layer is flows the sandbox only simulates. In Braintree, test card numbers fail in production, and a settled test transaction costs real money. Cross River simulates all card interactions in the sandbox, so ATM withdrawals, refunds, and ACH only actually run once you're in production.

What do these five layers look like in code?

Take a hypothetical example: you're integrating a gym chain's membership system with a recurring billing API. The code references two IDs: the plan

plan_gold

and the coupon code

coupon_welcome10

. Two weeks before launch, the first task is to write a preflight script that runs directly against production.

REQUIRED_IDS = ["plan_gold", "coupon_welcome10"]  # 代码引用的 ID

def preflight(env):
    errors = []
    if "sandbox" in env.base_url:
        errors.append("基础 URL 仍指向沙箱")
    if env.account_api_version != env.pinned_api_version:
        errors.append(f"API 版本不一致:{env.account_api_version}")
    missing = [i for i in REQUIRED_IDS if not env.object_exists(i)]
    if missing:
        errors.append(f"生产环境缺少对象:{missing}")
    if not env.webhook_registered(env.webhook_url):
        errors.append("生产环境 Webhook 未注册")
    if not env.secret_store.has("live_token"):
        errors.append("生产令牌不在密钥库中")
    return errors

The script deliberately skips layers four and five. Limits and compliance review are human work, so they go into an owned task list, not into code.

The second part is the webhook handler. It must survive duplicate and out-of-order events:

def handle(event):
    if already_processed(event.id):
        return 200  # 重复事件:跳过,但仍返回 200
    latest = fetch_object(event.object_id)  # 读取最新状态,不依赖事件顺序
    apply_state(latest)
    mark_processed(event.id)
    return 200

Notice the

fetch_object

line. Instead of inferring state from the event sequence, the handler queries the current state directly. That way, even if a "canceled" event arrives before an "activated" event, the membership record doesn't get corrupted.

Production says "no" where the sandbox never did

The script can't test limits, but the code still needs to know what to do when it gets blocked. Suppose your integration also handles payments, and a transfer is rejected for exceeding a project limit. The safe move is to pause the transfer and notify the responsible person, rather than letting a retry loop slam into the same wall over and over.

def submit_transfer(transfer):
    result = api.create_transfer(transfer)
    if result.ok:
        return mark_sent(transfer)
    if result.is_limit_rejection:  # 具体错误码请查阅服务商文档
        mark_on_hold(transfer, reason=result.message)
        notify(owner="limit_owner", item=transfer)
        return
    raise IntegrationError(result)  # 未知错误:停止并上报,不自动重试
is_limit_rejection

The branch answers, in advance, a question the sandbox never asks. The layer-five step is the first real transaction, covered below.

Doing it yourself: in what order?

Start with the provider's documentation: the launch checklist page, and the sandbox-versus-production comparison page if one exists. Sort every item into one of the five layers. For every line, specify who owns it: you, the customer's engineering team, or the account holder on the customer's side.

Then front-load the work that depends on others. Compliance review is approved by the provider, and its timing is out of your control, so submit the payment page for review early. Next, create the production token together with the account holder, and store it directly in the secrets vault in the same session.

Finally, agree with the customer on the first real transaction. Test cards don't work in production, and real card flows can only be verified in production, so you must run a small transaction with real money. Ask in advance: whose card, how much, who refunds it, and who watches the limits.

A few bad launch mornings a preflight script can prevent

Scenario one: the first member picks the Gold plan, and the signup page errors out. The plan was recreated in production with the right name but a different ID, so

plan_gold

doesn't exist. The first to discover the problem is the customer's front-desk staff, not you.

Scenario two is subtler. A member cancels their membership, but the production webhook was never registered, so the customer's system receives nothing and the membership card still shows "active." This kind of bug can go unnoticed for weeks.

Scenario three: the customer's account uses a different API version than the one the code was written against. The webhook payload structure changed, the handler reads the wrong fields, data silently corrupts, and no error is ever thrown. A preflight script would have caught all three problems two weeks earlier.

What the script can't catch are error paths that never ran. Stripe advises not waiting until launch to discover your code doesn't handle every type of error, including the ones you think will "never" happen. Missing data, bad data, and duplicate data all need to be tested in advance.

On a resume, a line like "wrote a preflight script for a payments integration and caught an unregistered production webhook before launch" is more convincing than a list of framework names. If a job posting mentions launch, prepare one concrete difference like this to expand on in the interview.

The best launch is the one with nothing to report, because every difference was found two weeks earlier.

Was this article helpful?

Thanks for your feedback!

4 sources

Next on the roadmap · Phase 2: Full-stack engineering. Migrate to Next.js—step one, don't touch routing; wrap the legacy single-page app in a catch-all route to get it running, then migrate pages one by one to the server.