hyperswitch
hyperswitch copied to clipboard
feat(users): refactor `ProdIntent` to support product-type context and merchant-scope
Type of Change
- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
This PR introduces support for associating ProdIntent with specific product_types and transitions the feature from being user-scoped to merchant-scoped, enabling more flexible usage across different products.
Changes Introduced
1. New V2 Routes for Dashboard Metadata
- Added v2 routes to support
ProdIntentcreation and retrieval with respect toproduct_type.
2. Product-Type Context for ProdIntent
- While inserting the
ProdIntentinto thedashboard_metadatatable (for both v1 and v2 schemas), theproduct_typeis now included in the metadata.
3. Merchant-Scoped ProdIntent
- Before:
ProdIntentwas user-scoped, allowing a single request per user. - Now: It is merchant-scoped, allowing a user to raise separate
ProdIntentrequests for different merchant accounts for each product by the same user.
4. Enhanced Email Body
- The email body sent for
ProdIntentnow includes theproduct_typecontext, helping understand for which product the prod intent was raised.
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
Enable requesting for Production Access for every product type merchant account.
How did you test it?
Hit the curl:
- Dashboard Metadata - ProdIntent (POST):
curl --location 'http://localhost:8080/user/data' \
--header 'accept: */*' \
--header 'accept-language: en-US,en;q=0.9' \
--header 'api-key: hyperswitch' \
--header 'content-type: application/json' \
--header 'origin: https://app.hyperswitch.io' \
--header 'priority: u=1, i' \
--header 'referer: https://app.hyperswitch.io/dashboard/home' \
--header 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-fetch-site: same-origin' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
--header 'x-merchant-id: merchant_1715600622' \
--header 'x-profile-id: pro_CqAdpUQBUUam1n0g56mB' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiOWExMGExMTYtZDc1Ny00MjBlLTkzNWQtZWRlZmQ5ZmQ3NTFmIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzQzMDUxMDM3Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTc0MzIyMzg0Mywib3JnX2lkIjoib3JnX1h5ZmR4eUttS1RGTEtuNTJ1clBVIiwicHJvZmlsZV9pZCI6InByb190Y3NsZWJDNDhmN1pkNG9mVlRqWCIsInRlbmFudF9pZCI6InB1YmxpYyJ9.NuvkkzrYPcba0JKUUrlM39NfyD2rHZ_jHIkHgPyM39s' \
--header 'Cookie: login_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMzcwZWUwYWUtZDI0ZS00ODJhLTlmNDktZDYzYmZkNGE0ZjVhIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF9qdmMzb1dXRmxkb0xHNG1GbFc0UCIsInJvbGVfaWQiOiJvcmdfYWRtaW4iLCJleHAiOjE3NDMxMDQxMzcsIm9yZ19pZCI6Im9yZ19hU3NCOWozTWVJcWxVS0YwbDJxRCIsInByb2ZpbGVfaWQiOiJwcm9fcGdrWUkzcnl6TlU2NlBLa3A4ZjciLCJ0ZW5hbnRfaWQiOiJwdWJsaWMifQ.oRERTxTsgrZWNXwSJ5w8CvDHOW1qB2GV3wBQ5Mv-BC8' \
--data-raw '{
"ProdIntent": {
"poc_email": "[email protected]",
"is_completed": true,
"legal_business_name": "blueberry",
"business_location": "IN",
"business_website": "https://google.com",
"poc_name": "berry",
"comments": "tx123"
}
}'
Dashboard Metadata table should get inserted/updated with the record along with the product_type in the json body.
Sample entry to table:
Also, product_type should also be sent in the email body to the configured recepient email-id.
- Dashboard Metadata - ProdIntent (GET):
curl --location 'http://localhost:8080/user/data?keys=ProdIntent' \
--header 'X-Merchant-Id: ddcd_oBuAVsHl0XMLag9JsHCV' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiM2RlMDFhYWYtOWVkMi00YTY5LTg3YWItNWU1YmI2ZWFiNGQ5IiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzQyMjEyMzQxIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTc0Mjk4MDgyOCwib3JnX2lkIjoib3JnX3pMQmRNTnpLaDZrNmhiT2tockdJIiwicHJvZmlsZV9pZCI6InByb19LWnhHZ21rUHFkMldQdXBFa2psWCIsInRlbmFudF9pZCI6InB1YmxpYyJ9.aD185AZEOcIjHnLnZZ9GJ2ujSHIdRPbPtrYhzNo0V4M' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'Referer: https://integ.hyperswitch.io/dashboard/v2/recon' \
--header 'sec-ch-ua: "Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"' \
--header 'X-Profile-Id: pro_UaxaxwTw4A0a9D0QNBrf' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'api-key: hyperswitch' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36' \
--header 'Content-Type: application/json'
Expected Output:
[
{
"ProdIntent": {
"legal_business_name": "blueberry",
"business_label": null,
"business_location": "IN",
"display_name": null,
"poc_email": "[email protected]",
"business_type": null,
"business_identifier": null,
"business_website": "https://google.com",
"poc_name": "berry",
"poc_contact": null,
"comments": "tx123",
"is_completed": true,
"product_type": "orchestration"
}
}
]
Similarly v2 routes:
http://localhost:8080/v2/user/data (POST)
http://localhost:8080/v2/user/data?keys=ProdIntent (GET)
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