Adyen / Adyen/adyen-node-api-library

[Feature]: Default region for Terminal API URL

Open Beginner friendly
#1,785 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

do not stale Feature good first issue
Dominant language
TypeScript
Stars
138
Forks
95
Avg merge
18h 31m
Merged PRs (30d)
30

Description

Feature summary

Add a default region for Terminal API in LIVE

Problem statement

Currently, region need to specified for LIVE env if not, there will be no default region URL defined and this will lead to "URL Invalid" error

if (!this.config.environment) {
            throw new Error("Environment must be defined");
        }

        // set Terminal API endpoints 
        if (this.config.environment === EnvironmentEnum.TEST) {
            // one TEST endpoint for all regions
            this.config.terminalApiCloudEndpoint = TERMINAL_API_ENDPOINT_TEST;
        } else if (this.config.environment === EnvironmentEnum.LIVE) {
            // region-based LIVE endpoints
            if(this.config.region) {
                if (!Config.isRegionValid(this.config.region)) {
                    throw new Error(`Invalid region provided: ${this.config.region}`);
                }
                this.config.terminalApiCloudEndpoint = Config.getTerminalApiEndpoint(this.config.region);  
            }
        }
Proposed solution

Implement the same solution as seen in Java Library

// For LIVE environment, lookup the endpoint using the map
    if (environment.equals(Environment.LIVE)) {
      if (region == null) {
        return Region.TERMINAL_API_ENDPOINTS_MAPPING.get(Region.EU);
      }
      if (!Region.TERMINAL_API_ENDPOINTS_MAPPING.containsKey(region)) {
        throw new IllegalArgumentException(
            "TerminalAPI endpoint for " + region + " is not supported yet");
      }
      return Region.TERMINAL_API_ENDPOINTS_MAPPING.getOrDefault(region, TERMINAL_API_ENDPOINT_LIVE);
    }
Alternatives considered

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript Config logic around EnvironmentEnum.LIVE and terminalApiCloudEndpoint, comparing the proposed behavior with the Java Library example. Done when LIVE without a region uses the EU endpoint while unsupported explicit regions still produce the appropriate validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.