refactor(customers_v2): include minor fixes for customer v2 flows (#6876)

This commit is contained in:
Sanchith Hegde
2024-12-20 13:26:39 +05:30
committed by GitHub
parent 81b324caf1
commit 5cdeaf8e60
5 changed files with 46 additions and 8 deletions

View File

@ -14585,6 +14585,7 @@
"id", "id",
"status", "status",
"amount", "amount",
"customer_id",
"connector", "connector",
"client_secret", "client_secret",
"created", "created",
@ -14606,6 +14607,13 @@
"amount": { "amount": {
"$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse" "$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse"
}, },
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
"example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
"connector": { "connector": {
"type": "string", "type": "string",
"description": "The connector used for the payment", "description": "The connector used for the payment",
@ -16330,6 +16338,7 @@
"id", "id",
"status", "status",
"amount", "amount",
"customer_id",
"client_secret", "client_secret",
"created" "created"
], ],
@ -16347,6 +16356,13 @@
"amount": { "amount": {
"$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse" "$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse"
}, },
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
"example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
"connector": { "connector": {
"type": "string", "type": "string",
"description": "The connector used for the payment", "description": "The connector used for the payment",

View File

@ -1,6 +1,8 @@
use common_utils::events::{ApiEventMetric, ApiEventsType}; use common_utils::events::{ApiEventMetric, ApiEventsType};
use crate::customers::{CustomerDeleteResponse, CustomerRequest, CustomerResponse}; use crate::customers::{
CustomerDeleteResponse, CustomerRequest, CustomerResponse, CustomerUpdateRequestInternal,
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerDeleteResponse { impl ApiEventMetric for CustomerDeleteResponse {
@ -55,7 +57,7 @@ impl ApiEventMetric for CustomerResponse {
} }
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal { impl ApiEventMetric for CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> { fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer { Some(ApiEventsType::Customer {
customer_id: self.customer_id.clone(), customer_id: self.customer_id.clone(),
@ -64,7 +66,7 @@ impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
} }
#[cfg(all(feature = "v2", feature = "customer_v2"))] #[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal { impl ApiEventMetric for CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> { fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer { Some(ApiEventsType::Customer {
customer_id: Some(self.id.clone()), customer_id: Some(self.id.clone()),

View File

@ -4803,6 +4803,15 @@ pub struct PaymentsConfirmIntentResponse {
/// Amount related information for this payment and attempt /// Amount related information for this payment and attempt
pub amount: ConfirmIntentAmountDetailsResponse, pub amount: ConfirmIntentAmountDetailsResponse,
/// The identifier for the customer
#[schema(
min_length = 32,
max_length = 64,
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
/// The connector used for the payment /// The connector used for the payment
#[schema(example = "stripe")] #[schema(example = "stripe")]
pub connector: String, pub connector: String,
@ -4872,6 +4881,15 @@ pub struct PaymentsRetrieveResponse {
/// Amount related information for this payment and attempt /// Amount related information for this payment and attempt
pub amount: ConfirmIntentAmountDetailsResponse, pub amount: ConfirmIntentAmountDetailsResponse,
/// The identifier for the customer
#[schema(
min_length = 32,
max_length = 64,
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
/// The connector used for the payment /// The connector used for the payment
#[schema(example = "stripe")] #[schema(example = "stripe")]
pub connector: Option<String>, pub connector: Option<String>,

View File

@ -568,7 +568,7 @@ pub async fn delete_customer(
) -> errors::CustomerResponse<customers::CustomerDeleteResponse> { ) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {
let db = &*state.store; let db = &*state.store;
let key_manager_state = &(&state).into(); let key_manager_state = &(&state).into();
id.fetch_domain_model_and_update_and_generate_delete_customer_response( id.redact_customer_details_and_generate_response(
db, db,
&key_store, &key_store,
&merchant_account, &merchant_account,
@ -585,7 +585,7 @@ pub async fn delete_customer(
))] ))]
#[async_trait::async_trait] #[async_trait::async_trait]
impl CustomerDeleteBridge for id_type::GlobalCustomerId { impl CustomerDeleteBridge for id_type::GlobalCustomerId {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>( async fn redact_customer_details_and_generate_response<'a>(
&'a self, &'a self,
db: &'a dyn StorageInterface, db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore, key_store: &'a domain::MerchantKeyStore,
@ -717,7 +717,7 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {
#[async_trait::async_trait] #[async_trait::async_trait]
trait CustomerDeleteBridge { trait CustomerDeleteBridge {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>( async fn redact_customer_details_and_generate_response<'a>(
&'a self, &'a self,
db: &'a dyn StorageInterface, db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore, key_store: &'a domain::MerchantKeyStore,
@ -742,7 +742,7 @@ pub async fn delete_customer(
let db = &*state.store; let db = &*state.store;
let key_manager_state = &(&state).into(); let key_manager_state = &(&state).into();
customer_id customer_id
.fetch_domain_model_and_update_and_generate_delete_customer_response( .redact_customer_details_and_generate_response(
db, db,
&key_store, &key_store,
&merchant_account, &merchant_account,
@ -759,7 +759,7 @@ pub async fn delete_customer(
))] ))]
#[async_trait::async_trait] #[async_trait::async_trait]
impl CustomerDeleteBridge for id_type::CustomerId { impl CustomerDeleteBridge for id_type::CustomerId {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>( async fn redact_customer_details_and_generate_response<'a>(
&'a self, &'a self,
db: &'a dyn StorageInterface, db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore, key_store: &'a domain::MerchantKeyStore,

View File

@ -1238,6 +1238,7 @@ where
id: payment_intent.id.clone(), id: payment_intent.id.clone(),
status: payment_intent.status, status: payment_intent.status,
amount, amount,
customer_id: payment_intent.customer_id.clone(),
connector, connector,
client_secret: payment_intent.client_secret.clone(), client_secret: payment_intent.client_secret.clone(),
created: payment_intent.created_at, created: payment_intent.created_at,
@ -1311,6 +1312,7 @@ where
id: payment_intent.id.clone(), id: payment_intent.id.clone(),
status: payment_intent.status, status: payment_intent.status,
amount, amount,
customer_id: payment_intent.customer_id.clone(),
connector, connector,
billing: payment_address billing: payment_address
.get_payment_billing() .get_payment_billing()