Skip to content

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Jan 12, 2024

Type of Change

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

Description

This PR adds recon APIs for activating recon as a feature on HyperSwitch dashboard and generating tokens for Recon dashboard.

Issue - #3359

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?

Tested below endpoints for Recon service using the attached postman collection.
Postman collection - https://galactic-capsule-229427.postman.co/workspace/My-Workspace~2b563e0d-bad3-420f-8c0b-0fd5b278a4fe/collection/9906252-4ef01bc4-53d4-40c0-a3e7-c84c8e32f105?action=share&creator=9906252

Endpoints

  1. /recon/update_merchant - admin API call for updating any recon related field for a given merchant.
  2. /recon/token - request a token for an user which is used for logging into Recon's dashboard.
  3. /recon/request - let's user send a mail to HS team for enabling recon for their merchant's account.
  4. /recon/verify_token - validate a generated token.

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


#[derive(Debug, serde::Serialize)]
pub struct ReconTokenResponse {
pub token: String,
Copy link
Member

Choose a reason for hiding this comment

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

If this contains sensitive information, let's use a Secret<String> instead.

.await
.change_context(UserErrors::InternalServerError)
.map_err(|error| {
logger::error!(?error);
Copy link
Member

Choose a reason for hiding this comment

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

Can we include more information about the error? That we were unable to send recon email, for example?

.update_merchant(merchant_account, updated_merchant_account, &key_store)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable_lazy(|| format!("Failed while updating merchant: {merchant_id}"))?;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.attach_printable_lazy(|| format!("Failed while updating merchant: {merchant_id}"))?;
.attach_printable_lazy(|| format!("Failed while updating recon status for merchant: {merchant_id}"))?;

Please make the same change elsewhere in this file.

.await
.change_context(UserErrors::InternalServerError)
.map_err(|error| {
logger::error!(?error);
Copy link
Member

Choose a reason for hiding this comment

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

Let's include more information about the error for better debugging.

@kashif-m kashif-m self-assigned this Jan 16, 2024
@kashif-m kashif-m added the C-feature Category: Feature request or enhancement label Jan 16, 2024
let user_from_db = db
.find_user_by_id(&user.user_id)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Even if the user is not found we raise this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if the control reaches till here, that means the auth token was verified, but user does not exist in DB

Probably that's why this is InternalServerError, should never reach here if the auth token was verified.

@likhinbopanna likhinbopanna linked an issue Jan 16, 2024 that may be closed by this pull request
2 tasks
@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 16, 2024
Merged via the queue into main with commit 8678f8d Jan 16, 2024
@likhinbopanna likhinbopanna deleted the recon_apis branch January 16, 2024 11:22
pixincreate added a commit that referenced this pull request Jan 17, 2024
* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.01.17.0
  feat(connector): [BANKOFAMERICA] Implement 3DS flow for cards (#3343)
  ci(s3): fetch connector creds from s3 for added security (#3323)
  feat(recon): add recon APIs (#3345)
  fix(payment_link): added expires_on in payment response (#3332)
  fix(connector_onboarding): Check if connector exists for the merchant account and add reset tracking id API (#3229)
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] Recon APIs
5 participants