feat(merchant_account): add merchant account create v2 route (#5061)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
Co-authored-by: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com>
Co-authored-by: Sarthak Soni <76486416+Sarthak1799@users.noreply.github.com>
Co-authored-by: Sandeep Kumar <83278309+tsdk02@users.noreply.github.com>
Co-authored-by: Abhitator216 <abhishek.kanojia@juspay.in>
Co-authored-by: Abhishek Kanojia <89402434+Abhitator216@users.noreply.github.com>
Co-authored-by: ivor-juspay <138492857+ivor-juspay@users.noreply.github.com>
Co-authored-by: Sampras Lopes <sampras.lopes@juspay.in>
Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com>
Co-authored-by: likhinbopanna <131246334+likhinbopanna@users.noreply.github.com>
Co-authored-by: Sahkal Poddar <sahkalplanet@gmail.com>
Co-authored-by: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com>
Co-authored-by: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
Co-authored-by: GORAKHNATH YADAV <gorakhcodes@gmail.com>
Co-authored-by: Apoorv Dixit <64925866+apoorvdixit88@users.noreply.github.com>
Co-authored-by: ShivanshMathurJuspay <104988143+ShivanshMathurJuspay@users.noreply.github.com>
Co-authored-by: awasthi21 <107559116+awasthi21@users.noreply.github.com>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
This commit is contained in:
Narayan Bhat
2024-07-10 13:15:36 +05:30
committed by GitHub
parent fa7add19ee
commit d6b9151e9e
36 changed files with 1568 additions and 972 deletions

View File

@ -6,7 +6,7 @@ use masking::{PeekInterface, Secret};
use crate::{
consts::ID_LENGTH,
id_type::{CustomerId, MerchantReferenceId},
id_type::{CustomerId, LengthId},
};
pub mod access_token;
@ -21,6 +21,7 @@ pub mod fp_utils;
pub mod id_type;
pub mod link_utils;
pub mod macros;
pub mod new_type;
pub mod pii;
#[allow(missing_docs)] // Todo: add docs
pub mod request;
@ -207,16 +208,16 @@ pub fn generate_id(length: usize, prefix: &str) -> String {
format!("{}_{}", prefix, nanoid::nanoid!(length, &consts::ALPHABETS))
}
/// Generate a MerchantRefId with the default length
fn generate_merchant_ref_id_with_default_length<const MAX_LENGTH: u8, const MIN_LENGTH: u8>(
/// Generate a ReferenceId with the default length with the given prefix
fn generate_ref_id_with_default_length<const MAX_LENGTH: u8, const MIN_LENGTH: u8>(
prefix: &str,
) -> MerchantReferenceId<MAX_LENGTH, MIN_LENGTH> {
MerchantReferenceId::<MAX_LENGTH, MIN_LENGTH>::new(prefix)
) -> LengthId<MAX_LENGTH, MIN_LENGTH> {
LengthId::<MAX_LENGTH, MIN_LENGTH>::new(prefix)
}
/// Generate a customer id with default length
/// Generate a customer id with default length, with prefix as `cus`
pub fn generate_customer_id_of_default_length() -> CustomerId {
CustomerId::new(generate_merchant_ref_id_with_default_length("cus"))
CustomerId::new(generate_ref_id_with_default_length("cus"))
}
/// Generate a nanoid with the given prefix and a default length
@ -272,7 +273,7 @@ mod nanoid_tests {
#[test]
fn test_generate_merchant_ref_id_with_default_length() {
let ref_id = MerchantReferenceId::<
let ref_id = LengthId::<
MAX_ALLOWED_MERCHANT_REFERENCE_ID_LENGTH,
MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH,
>::from(generate_id_with_default_len("def").into());