Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Org KYC #873

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

feat: add support for Org KYC #873

wants to merge 7 commits into from

Conversation

whoAbhishekSah
Copy link
Member

@whoAbhishekSah whoAbhishekSah commented Feb 19, 2025

Description

Enterprise Organizations require KYC approval for compliance purposes. This feature enables KYC management on any org. Companion PR: raystack/proton#378

It adds the following two endpoints(over GRPC-Gateway proxied to RPC interface):

Set KYC (Admin)

PUT: "/v1beta1/admin/organizations/{org_id}/kyc"

With the request body:

{
  "status": true,
  "link": "string"
}

Get KYC

GET: "/v1beta1/organizations/{org_id}/kyc"

Testing

Set KYC

Happy Path

curl --location --request PUT 'localhost:8000/v1beta1/admin/organizations/143d7078-b1eb-4fb8-a0e0-a00e453cc633/kyc' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah' \
--data '{
  "status": true,
  "link": "abcd"
}'

Gives the response:

{
    "organization_kyc": {
        "org_id": "blah",
        "status": true,
        "link": "abcd",
        "created_at": null,
        "updated_at": null
    }
}

If link is not provided when KYC status is set to true

curl --location --request PUT 'localhost:8000/v1beta1/admin/organizations/143d7078-b1eb-4fb8-a0e0-a00e453cc633/kyc' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah' \
--data '{
  "status": true,
  "link": ""
}'

Response: 400 Bad Request

{"code":3, "message":"link cannot be empty", "details":[]}

If the org is not there itself

curl --location --request PUT 'localhost:8000/v1beta1/admin/organizations/143d7078-b1eb-4fb8-a0e0-a00e453cc633/kyc' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah' \
--data '{
  "status": true,
  "link": "fgdsdgsdfgsdgsd"
}'

Response: 400 Bad Request

{
    "code": 3,
    "message": "org doesn't exist",
    "details": []
}

Invalid Org UUID passed in path param

curl --location --request PUT 'localhost:8000/v1beta1/admin/organizations/blah/kyc' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah' \
--data '{
  "status": true,
  "link": "fgdsdgsdfgsdgsd"
}'

Response: 400 Bad Request

{
    "code": 3,
    "message": "invalid syntax of uuid",
    "details": []
}

Get KYC

Happy Path

curl --location 'localhost:8000/v1beta1/organizations/143d7078-b1eb-4fb8-a0e0-a00e453cc633/kyc' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah'
{
    "organization_kyc": {
        "org_id": "143d7078-b1eb-4fb8-a0e0-a00e453cc633",
        "status": true,
        "link": "fgdsdgsdfgsdgsd",
        "created_at": "2025-02-20T09:47:12.682838Z",
        "updated_at": "2025-02-20T09:47:12.682838Z"
    }
}

If Org kyc doesn't exist, 404 error will be thrown.

curl --location 'localhost:8000/v1beta1/organizations/143d7078-b1eb-4fb8-a0e0-a00e453cc633/kyc' \
--header 'Accept: application/json' \
--header 'Cookie: sid=blah'

Response:

HTTP Resp: 404 Not Found

{
    "code": 5,
    "message": "org kyc doesn't exist",
    "details": []
}

All other errors are returned as, 500 Internal Server Error

Response:

{
    "code": 13,
    "message": "internal server error",
    "details": []
}

with the following log on the service:

2025-02-20T15:12:52.124+0530    error   some random error       {"grpc.start_time": "2025-02-20T15:12:52+05:30", "system": "grpc", "span.kind": "server", "grpc.service": "raystack.frontier.v1beta1.FrontierService", "grpc.method": "GetOrganizationKyc", "peer.address": "127.0.0.1:62401"}
2025-02-20T15:12:52.125+0530    error   finished unary call with code Internal  {"grpc.start_time": "2025-02-20T15:12:52+05:30", "system": "grpc", "span.kind": "server", "grpc.service": "raystack.frontier.v1beta1.FrontierService", "grpc.method": "GetOrganizationKyc", "error": "rpc error: code = Internal desc = internal server error", "grpc.code": "Internal", "grpc.time_ms": 27.393}

Copy link

vercel bot commented Feb 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 9:32am

Copy link
Contributor

Pull Request Test Coverage Report for Build 13407738805

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 32.363%

Totals Coverage Status
Change from base Build 13407714034: 0.0%
Covered Lines: 8251
Relevant Lines: 25495

💛 - Coveralls

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.

1 participant