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

@ -2,11 +2,14 @@ use actix_web::{web, Scope};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use super::customers::*;
use super::{payment_intents::*, refunds::*, setup_intents::*, webhooks::*};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use super::{payment_intents::*, setup_intents::*};
use super::{refunds::*, webhooks::*};
use crate::routes::{self, mandates, webhooks};
pub struct PaymentIntents;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl PaymentIntents {
pub fn server(state: routes::AppState) -> Scope {
let mut route = web::scope("/payment_intents").app_data(web::Data::new(state));
@ -42,6 +45,7 @@ impl PaymentIntents {
pub struct SetupIntents;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl SetupIntents {
pub fn server(state: routes::AppState) -> Scope {
web::scope("/setup_intents")

View File

@ -6,6 +6,7 @@ use common_utils::{crypto::Encryptable, date_time};
use common_utils::{
id_type,
pii::{self, Email},
types::Description,
};
use serde::{Deserialize, Serialize};
@ -40,7 +41,7 @@ pub struct CreateCustomerRequest {
pub phone: Option<masking::Secret<String>>,
pub address: Option<StripeAddressDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
pub description: Option<String>,
pub description: Option<Description>,
pub shipping: Option<Shipping>,
pub payment_method: Option<String>, // not used
pub balance: Option<i64>, // not used
@ -59,7 +60,7 @@ pub struct CreateCustomerRequest {
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct CustomerUpdateRequest {
pub description: Option<String>,
pub description: Option<Description>,
pub email: Option<Email>,
pub phone: Option<masking::Secret<String, masking::WithType>>,
pub name: Option<masking::Secret<String>>,
@ -85,7 +86,7 @@ pub struct CreateCustomerResponse {
pub id: id_type::CustomerId,
pub object: String,
pub created: u64,
pub description: Option<String>,
pub description: Option<Description>,
pub email: Option<Email>,
pub metadata: Option<pii::SecretSerdeValue>,
pub name: Option<masking::Secret<String>>,

View File

@ -2,18 +2,25 @@ pub mod types;
use actix_web::{web, HttpRequest, HttpResponse};
use api_models::payments as payment_types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use error_stack::report;
use router_env::{instrument, tracing, Flow, Tag};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use router_env::Tag;
use router_env::{instrument, tracing, Flow};
use crate::{
compatibility::{stripe::errors, wrap},
core::{api_locking::GetLockingInput, payments},
logger,
routes::{self, payments::get_or_generate_payment_id},
core::payments,
routes::{self},
services::{api, authentication as auth},
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::{
core::api_locking::GetLockingInput, logger, routes::payments::get_or_generate_payment_id,
types::api as api_types,
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCreate, payment_id))]
pub async fn payment_intents_create(
state: web::Data<routes::AppState>,
@ -78,6 +85,8 @@ pub async fn payment_intents_create(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsRetrieveForceSync))]
pub async fn payment_intents_retrieve(
state: web::Data<routes::AppState>,
@ -139,6 +148,8 @@ pub async fn payment_intents_retrieve(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow))]
pub async fn payment_intents_retrieve_with_gateway_creds(
state: web::Data<routes::AppState>,
@ -210,6 +221,8 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsUpdate))]
pub async fn payment_intents_update(
state: web::Data<routes::AppState>,
@ -277,6 +290,8 @@ pub async fn payment_intents_update(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsConfirm, payment_id))]
pub async fn payment_intents_confirm(
state: web::Data<routes::AppState>,
@ -350,6 +365,8 @@ pub async fn payment_intents_confirm(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCapture, payment_id))]
pub async fn payment_intents_capture(
state: web::Data<routes::AppState>,
@ -412,6 +429,8 @@ pub async fn payment_intents_capture(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCancel, payment_id))]
pub async fn payment_intents_cancel(
state: web::Data<routes::AppState>,

View File

@ -1,10 +1,14 @@
pub mod types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use actix_web::{web, HttpRequest, HttpResponse};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use api_models::payments as payment_types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use error_stack::report;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use router_env::{instrument, tracing, Flow};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::{
compatibility::{
stripe::{errors, payment_intents::types as stripe_payment_types},
@ -16,6 +20,7 @@ use crate::{
types::api as api_types,
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCreate))]
pub async fn setup_intents_create(
state: web::Data<routes::AppState>,
@ -79,6 +84,8 @@ pub async fn setup_intents_create(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsRetrieveForceSync))]
pub async fn setup_intents_retrieve(
state: web::Data<routes::AppState>,
@ -140,6 +147,8 @@ pub async fn setup_intents_retrieve(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsUpdate))]
pub async fn setup_intents_update(
state: web::Data<routes::AppState>,
@ -213,6 +222,8 @@ pub async fn setup_intents_update(
))
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsConfirm))]
pub async fn setup_intents_confirm(
state: web::Data<routes::AppState>,