Skip to content

refactor(errors): namespace provider error codes in gatewayErrorMap - #68

Open
MargaretKerubo wants to merge 2 commits into
Flying-Tea-Squad:mainfrom
MargaretKerubo:feat/error-namespaces
Open

MargaretKerubo wants to merge 2 commits into
Flying-Tea-Squad:mainfrom
MargaretKerubo:feat/error-namespaces

Conversation

@MargaretKerubo

Copy link
Copy Markdown

Summary

This PR restructures the gatewayErrorMap into a nested map (map[string]map[string]string) to prevent collisions between different payment providers that might reuse the same raw error codes.

It fulfills the requirements of Issue #63 by:

  • Grouping M-Pesa error codes under an "mpesa" namespace.
  • Creating a "default" namespace for the generic error code examples.
  • Updating the MapGatewayErrorCode function signature to accept a provider argument, allowing it to search the provider-specific map before falling back to the "default" map.

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation

Related issue

Closes #63

Details

  • Changed gatewayErrorMap type to map[string]map[string]string.
  • Updated MapGatewayErrorCode(provider, code string) string to check the provider namespace first, then fall back to "default".
  • Verified that there are no current usages of MapGatewayErrorCode in the provider packages that need updating (this lays the groundwork for mapping M-Pesa endpoint responses in Issue Map M-Pesa endpoint responses onto shared paykit.Response #59).

Testing

  • Ran mise run ci locally. Verified that the code compiles, golangci-lint passes without warnings, and all existing tests pass (go test ./...).

Checklist

  • Tests added or updated
  • Documentation updated
  • go test ./... passes
  • Breaking changes documented

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Namespace provider error codes in gatewayErrorMap by provider

1 participant