feat(customer_v2): add customer create v2 endpoint (#5444)

Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sahkal Poddar
2024-08-07 13:12:10 +05:30
committed by GitHub
parent c6a960766d
commit 52cada015e
47 changed files with 1474 additions and 160 deletions

View File

@ -10,7 +10,7 @@ use common_utils::{errors::CustomResult, ext_traits::AsyncExt, types::MinorUnit}
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{payment_address::PaymentAddress, router_data::ErrorResponse};
#[cfg(feature = "payouts")]
use masking::PeekInterface;
use masking::{ExposeInterface, PeekInterface};
use maud::{html, PreEscaped};
use router_env::{instrument, tracing};
use uuid::Uuid;
@ -128,8 +128,14 @@ pub async fn construct_payout_router_data<'a, F>(
let connector_customer_id = customer_details
.as_ref()
.and_then(|c| c.connector_customer.as_ref())
.and_then(|cc| cc.get(connector_label))
.and_then(|id| serde_json::from_value::<String>(id.to_owned()).ok());
.and_then(|connector_customer_value| {
connector_customer_value
.clone()
.expose()
.get(connector_label)
.cloned()
})
.and_then(|id| serde_json::from_value::<String>(id).ok());
let vendor_details: Option<PayoutVendorAccountDetails> =
match api_models::enums::PayoutConnectors::try_from(connector_name.to_owned()).map_err(
@ -151,7 +157,7 @@ pub async fn construct_payout_router_data<'a, F>(
let router_data = types::RouterData {
flow: PhantomData,
merchant_id: merchant_account.get_id().to_owned(),
customer_id: customer_details.to_owned().map(|c| c.customer_id),
customer_id: customer_details.to_owned().map(|c| c.get_customer_id()),
connector_customer: connector_customer_id,
connector: connector_name.to_string(),
payment_id: "".to_string(),
@ -182,7 +188,7 @@ pub async fn construct_payout_router_data<'a, F>(
customer_details: customer_details
.to_owned()
.map(|c| payments::CustomerDetails {
customer_id: Some(c.customer_id),
customer_id: Some(c.get_customer_id()),
name: c.name.map(Encryptable::into_inner),
email: c.email.map(Email::from),
phone: c.phone.map(Encryptable::into_inner),