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(payouts): Add user roles for payouts #4167

Merged
merged 4 commits into from
Mar 22, 2024
Merged

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Mar 21, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR introduces user roles for Payouts. PayoutRead and PayoutWrite are added as permission under payout persmissions. This permission are added to list(get/post), retrieval and filter api's for payouts.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

User permissions are used while user accessing the payout data via dashboard. PayoutRead and PayoutWrite are added as permission under payout persmissions. This permission are added to list(get/post), retrieval and filter api's of payouts.

How did you test it?

  1. User with org_admin, internal_admin, merchant_admin, merchant_operator will have PayoutRead and PayourWrite. All other user roles will have only PayoutRead. This below curl will get information of user role permissions.
curl --location --request GET '{{base_url}}/user/permission_info' \
--header 'Authorization: {{user_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "[email protected]"
}'
  1. View all permissions from below curl
curl --location --request GET '{{base_url}}/user/role/list' \
--header 'Authorization: {{user_token}}'

Response :

[
    {
        "role_id": "merchant_view_only",
        "permissions": [
            "PayoutRead",
            "CustomerRead",
            "MerchantConnectorAccountRead",
            "MandateRead",
            "PaymentRead",
            "SurchargeDecisionManagerRead",
            "Analytics",
            "DisputeRead",
            "MerchantAccountRead",
            "RoutingRead",
            "UsersRead",
            "RefundRead",
            "ThreeDsDecisionManagerRead"
        ],
        "role_name": "view_only",
        "role_scope": "organization"
    },
    {
        "role_id": "merchant_iam_admin",
        "permissions": [
            "UsersWrite",
            "Analytics",
            "UsersRead",
            "PaymentRead",
            "MerchantAccountRead",
            "MandateRead",
            "DisputeRead",
            "PayoutRead",
            "RefundRead",
            "CustomerRead"
        ],
        "role_name": "iam",
        "role_scope": "organization"
    },
    {
        "role_id": "merchant_developer",
        "permissions": [
            "RefundRead",
            "PayoutRead",
            "MerchantAccountWrite",
            "ApiKeyWrite",
            "PaymentRead",
            "MerchantConnectorAccountRead",
            "UsersRead",
            "MandateRead",
            "DisputeRead",
            "MerchantAccountRead",
            "CustomerRead",
            "ApiKeyRead",
            "Analytics",
            "WebhookEventRead"
        ],
        "role_name": "developer",
        "role_scope": "organization"
    },
    {
        "role_id": "merchant_customer_support",
        "permissions": [
            "MandateRead",
            "PaymentRead",
            "DisputeRead",
            "PayoutRead",
            "MerchantAccountRead",
            "Analytics",
            "RefundRead",
            "CustomerRead",
            "UsersRead"
        ],
        "role_name": "customer_support",
        "role_scope": "organization"
    },
    {
        "role_id": "merchant_admin",
        "permissions": [
            "PayoutRead",
            "MandateWrite",
            "RoutingRead",
            "PayoutWrite",
            "RefundWrite",
            "MerchantConnectorAccountWrite",
            "SurchargeDecisionManagerRead",
            "DisputeRead",
            "RoutingWrite",
            "SurchargeDecisionManagerWrite",
            "Analytics",
            "ThreeDsDecisionManagerWrite",
            "MerchantAccountRead",
            "UsersRead",
            "MerchantConnectorAccountRead",
            "UsersWrite",
            "MandateRead",
            "MerchantAccountWrite",
            "ApiKeyRead",
            "ApiKeyWrite",
            "RefundRead",
            "WebhookEventRead",
            "PaymentWrite",
            "PaymentRead",
            "CustomerRead",
            "DisputeWrite",
            "ThreeDsDecisionManagerRead",
            "CustomerWrite"
        ],
        "role_name": "admin",
        "role_scope": "organization"
    },
    {
        "role_id": "merchant_operator",
        "permissions": [
            "RoutingRead",
            "PayoutWrite",
            "MerchantAccountRead",
            "SurchargeDecisionManagerRead",
            "PaymentWrite",
            "CustomerWrite",
            "MandateWrite",
            "DisputeWrite",
            "RefundWrite",
            "DisputeRead",
            "CustomerRead",
            "MerchantConnectorAccountRead",
            "ThreeDsDecisionManagerRead",
            "UsersRead",
            "PaymentRead",
            "MandateRead",
            "PayoutRead",
            "RefundRead",
            "Analytics"
        ],
        "role_name": "operator",
        "role_scope": "organization"
    }
]

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@srujanchikke srujanchikke added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Mar 21, 2024
@srujanchikke srujanchikke self-assigned this Mar 21, 2024
@srujanchikke srujanchikke requested review from a team as code owners March 21, 2024 10:46
@srujanchikke srujanchikke linked an issue Mar 21, 2024 that may be closed by this pull request
2 tasks
kashif-m
kashif-m previously approved these changes Mar 21, 2024
Copy link
Contributor

@kashif-m kashif-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumption of these roles look good in the retrieve + list + filter APIs.

@@ -31,6 +31,8 @@ pub enum Permission {
UsersRead,
UsersWrite,
MerchantAccountCreate,
PayoutWrite,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no APIs using this permission, this can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be used for generating reports, we don't have any APIs for it now, but we will in the future.

ThisIsMani
ThisIsMani previously approved these changes Mar 21, 2024
racnan
racnan previously approved these changes Mar 21, 2024
@srujanchikke srujanchikke dismissed stale reviews from racnan, ThisIsMani, and kashif-m via 23594ce March 22, 2024 05:38
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Mar 22, 2024
Merged via the queue into main with commit 13fe584 Mar 22, 2024
16 of 18 checks passed
@Gnanasundari24 Gnanasundari24 deleted the payout_user_permissions branch March 22, 2024 11:05
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add user roles for payouts
6 participants