diff --git a/src/core/authorizenet-base.ts b/src/core/authorizenet-base.ts index 924e9e8..75efa37 100644 --- a/src/core/authorizenet-base.ts +++ b/src/core/authorizenet-base.ts @@ -46,8 +46,12 @@ abstract class AuthorizenetBase extends AbstractPaymentProvider { this.options_ = options; this.logger = container.logger as Logger; this.container_ = container; + // Accept both the correct 'environment' key and the legacy misspelled + // 'enviornment' (see #1) so existing configs keep working. + const envOption = + this.options_.environment ?? this.options_.enviornment; this.solutionID = - this.options_.enviornment === "production" ? "AAA201051" : "AAA198606"; + envOption === "production" ? "AAA201051" : "AAA198606"; } static validateOptions(options: AuthorizenetOptions): void { @@ -91,7 +95,10 @@ abstract class AuthorizenetBase extends AbstractPaymentProvider { } // START GENAI private getEnvironment() { - return this.options_.enviornment === "production" + // Accept both 'environment' and the legacy misspelling 'enviornment' (#1). + const envOption = + this.options_.environment ?? this.options_.enviornment; + return envOption === "production" ? Constants.endpoint.production : Constants.endpoint.sandbox; } diff --git a/src/types/index.ts b/src/types/index.ts index e97cff7..20511ff 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -39,6 +39,11 @@ export interface Options { api_login_id: string; transaction_key: string; capture?: boolean; + environment?: string; + /** + * @deprecated Typo preserved for backward compatibility. Use `environment`. + * Will be removed in a future major version. + */ enviornment?: string; }