Skip to content

fix(core): honor correctly-spelled 'environment' option (with back-compat)#2

Open
MukundaKatta wants to merge 1 commit intoAuthorizeNet:mainfrom
MukundaKatta:codex/fix-environment-option-typo
Open

fix(core): honor correctly-spelled 'environment' option (with back-compat)#2
MukundaKatta wants to merge 1 commit intoAuthorizeNet:mainfrom
MukundaKatta:codex/fix-environment-option-typo

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

Per #1, `authorizenet-base.ts` reads `options.enviornment` (typo — missing `n` before `i`), so a Medusa config that sets the canonical `environment: "production"` is silently treated as sandbox. Live Accept.js nonces are rejected by sandbox, orders get created but payment is never captured — a real production-mode bug.

Non-breaking fix:

  1. `src/types/index.ts`:
    • Add `environment?: string` (canonical).
    • Keep `enviornment?: string` but mark `@deprecated` so IDE nudges users onto the right name.
  2. `src/core/authorizenet-base.ts`:
    • Two call sites (solutionID initialisation, `getEnvironment()`) now read `options.environment ?? options.enviornment`, so both spellings work.

Existing merchants who currently use the `enviornment` workaround keep working; anyone using the documented `environment` field starts behaving correctly.

Closes #1

Testing

  • Static grep: no `enviornment` reference remains as the only key anywhere.
  • Type-check: `Options` still compiles; both fields are optional.
  • Runtime flow: when `environment === "production"`, both `solutionID` and `getEnvironment()` now return the production values; when the legacy `enviornment === "production"` is set, same behavior.

…mpat for 'enviornment')

Per AuthorizeNet#1, the authorizenet-base code read options.enviornment (typo —
missing 'n' before 'i'), but the correctly-spelled 'environment' key
passed in medusa-config.ts was silently ignored. Merchants setting
environment: 'production' were hitting the sandbox endpoint, which
rejects live Accept.js nonces — orders created, payment never captured.

This PR:
- Adds an 'environment?' field to Options (canonical spelling).
- Keeps the legacy 'enviornment?' field, marked @deprecated, so existing
  configs continue to work without breaking.
- Both call sites (solutionID init, getEnvironment()) now read the
  correct key first, falling back to the legacy one.

Closes AuthorizeNet#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Bug: "environment" option misspelled as "enviornment" - production mode never activates

1 participant