hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat: store encrypted extended card info in redis

Open Chethan-rao opened this issue 10 months ago • 0 comments

Type of Change

  • [ ] Bugfix
  • [x] 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
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

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code
  • [ ] I added unit tests for my changes where possible

Chethan-rao avatar Apr 29 '24 13:04 Chethan-rao