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: store encrypted extended card info in redis #4493

Merged
merged 14 commits into from
May 2, 2024

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Apr 29, 2024

Type of Change

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

Description

While the customer is making a payment, we’ll check whether the extended card info feature is enabled through profile_id in the business profile. If enabled, we’ll fetch the merchant public_key and ttl from config. We’ll encrypt the card using the public key and store it in redis until ttl with the key being {merchant_id}_{payment_id}_extended_card_info.

This PR also makes the ttl field as an optional field. the default value would be 15 min (900 seconds) and max value would be 1 hr (3600 seconds).

Additional Changes

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

Motivation and Context

How did you test it?

  1. Create merchant account (get default profile_id)
  2. Create api key
  3. Create mca (any connector)
  4. Enable extended card info feature
curl --location 'http://localhost:8080/account/:merchant_id/business_profile/:profile_id/toggle_extended_card_info' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "enabled": true
}'

image

  1. Use update endpoint of business profile to pass config.
curl --location 'http://localhost:8080/account/:merchant_id/business_profile/:profile_id' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "extended_card_info_config": {
        "public_key": "pub_key_1",
        "ttl_in_secs": 60
    }
}'

image

  1. Create a normal card payment.
  2. Hit the endpoint to retrieve the payload (PR - feat: add an api for retrieving the extended card info from redis #4484)
curl --location 'http://localhost:8080/payments/pay_1nrIoi2hRnzsy1V2cEv6/extended_card_info' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_KM55eCA115eJaTBYK6Z8DYLwI6EghXzZDUb9M1RzE6Ji1jMEhs71C8c43ndOubXw' \
--data ''

image

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

@Chethan-rao Chethan-rao added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Apr 29, 2024
@Chethan-rao Chethan-rao added this to the April 2024 milestone Apr 29, 2024
@Chethan-rao Chethan-rao self-assigned this Apr 29, 2024
@Chethan-rao Chethan-rao requested review from a team as code owners April 29, 2024 13:04
@Chethan-rao Chethan-rao linked an issue Apr 29, 2024 that may be closed by this pull request
@Chethan-rao Chethan-rao changed the base branch from main to merchant-info-for-extended-card-feat April 29, 2024 13:07
@Chethan-rao Chethan-rao requested review from a team as code owners April 29, 2024 13:07
@Chethan-rao Chethan-rao changed the base branch from merchant-info-for-extended-card-feat to main April 29, 2024 13:07
@Chethan-rao Chethan-rao changed the base branch from main to merchant-info-for-extended-card-feat April 29, 2024 13:10
@Chethan-rao Chethan-rao force-pushed the store-encrypted-card-in-redis branch 2 times, most recently from d452f84 to 7313926 Compare April 29, 2024 16:35
@Chethan-rao Chethan-rao force-pushed the store-encrypted-card-in-redis branch from 7313926 to af2ca2d Compare April 30, 2024 13:40
Base automatically changed from merchant-info-for-extended-card-feat to main May 1, 2024 10:50
NishantJoshi00
NishantJoshi00 previously approved these changes May 1, 2024
crates/openapi/src/openapi.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 left a comment

Choose a reason for hiding this comment

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

No dashboard specific changes!

Copy link
Contributor

@srujanchikke srujanchikke left a comment

Choose a reason for hiding this comment

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

No connector specific changes are present.

@pixincreate pixincreate enabled auto-merge May 2, 2024 11:14
@pixincreate pixincreate added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit 6c59d24 May 2, 2024
21 of 27 checks passed
@pixincreate pixincreate deleted the store-encrypted-card-in-redis branch May 2, 2024 11:58
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 2, 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.

Store encrypted raw card info in redis
6 participants