mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	fix(customer): populate email from customer table if not present in request (#692)
This commit is contained in:
		| @ -584,16 +584,23 @@ pub(crate) async fn call_payment_method( | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| pub async fn get_customer_from_details( | pub async fn get_customer_from_details<F: Clone>( | ||||||
|     db: &dyn StorageInterface, |     db: &dyn StorageInterface, | ||||||
|     customer_id: Option<String>, |     customer_id: Option<String>, | ||||||
|     merchant_id: &str, |     merchant_id: &str, | ||||||
|  |     payment_data: &mut PaymentData<F>, | ||||||
| ) -> CustomResult<Option<storage::Customer>, errors::StorageError> { | ) -> CustomResult<Option<storage::Customer>, errors::StorageError> { | ||||||
|     match customer_id { |     match customer_id { | ||||||
|         None => Ok(None), |         None => Ok(None), | ||||||
|         Some(c_id) => { |         Some(c_id) => { | ||||||
|             db.find_customer_optional_by_customer_id_merchant_id(&c_id, merchant_id) |             let customer = db | ||||||
|                 .await |                 .find_customer_optional_by_customer_id_merchant_id(&c_id, merchant_id) | ||||||
|  |                 .await?; | ||||||
|  |             payment_data.email = payment_data | ||||||
|  |                 .email | ||||||
|  |                 .clone() | ||||||
|  |                 .or(customer.as_ref().and_then(|inner| inner.email.clone())); | ||||||
|  |             Ok(customer) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -663,6 +670,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>( | |||||||
|                 let customer = customer?; |                 let customer = customer?; | ||||||
|  |  | ||||||
|                 payment_data.payment_intent.customer_id = Some(customer.customer_id.clone()); |                 payment_data.payment_intent.customer_id = Some(customer.customer_id.clone()); | ||||||
|  |                 payment_data.email = payment_data.email.clone().or(customer.email.clone()); | ||||||
|  |  | ||||||
|                 Some(customer) |                 Some(customer) | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -183,6 +183,7 @@ where | |||||||
|                 db, |                 db, | ||||||
|                 payment_data.payment_intent.customer_id.clone(), |                 payment_data.payment_intent.customer_id.clone(), | ||||||
|                 merchant_id, |                 merchant_id, | ||||||
|  |                 payment_data, | ||||||
|             ) |             ) | ||||||
|             .await?, |             .await?, | ||||||
|         )) |         )) | ||||||
| @ -238,6 +239,7 @@ where | |||||||
|                 db, |                 db, | ||||||
|                 payment_data.payment_intent.customer_id.clone(), |                 payment_data.payment_intent.customer_id.clone(), | ||||||
|                 merchant_id, |                 merchant_id, | ||||||
|  |                 payment_data, | ||||||
|             ) |             ) | ||||||
|             .await?, |             .await?, | ||||||
|         )) |         )) | ||||||
| @ -292,6 +294,7 @@ where | |||||||
|                 db, |                 db, | ||||||
|                 payment_data.payment_intent.customer_id.clone(), |                 payment_data.payment_intent.customer_id.clone(), | ||||||
|                 merchant_id, |                 merchant_id, | ||||||
|  |                 payment_data, | ||||||
|             ) |             ) | ||||||
|             .await?, |             .await?, | ||||||
|         )) |         )) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Nishant Joshi
					Nishant Joshi