mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	fix(address): use first_name if last_name is not passed (#4360)
This commit is contained in:
		| @ -424,9 +424,10 @@ fn build_bill_to( | ||||
|         .ok_or_else(utils::missing_field_err("billing.address"))?; | ||||
|     let mut state = address.to_state_code()?.peek().clone(); | ||||
|     state.truncate(20); | ||||
|     let first_name = address.get_first_name()?; | ||||
|     Ok(BillTo { | ||||
|         first_name: address.get_first_name()?.to_owned(), | ||||
|         last_name: address.get_last_name()?.to_owned(), | ||||
|         first_name: first_name.clone(), | ||||
|         last_name: address.get_last_name().unwrap_or(first_name).clone(), | ||||
|         address1: address.get_line1()?.to_owned(), | ||||
|         locality: Secret::new(address.get_city()?.to_owned()), | ||||
|         administrative_area: Secret::from(state), | ||||
|  | ||||
| @ -1133,9 +1133,10 @@ fn get_card_holder_info( | ||||
|     address: &api::AddressDetails, | ||||
|     email: Email, | ||||
| ) -> CustomResult<Option<BluesnapCardHolderInfo>, errors::ConnectorError> { | ||||
|     let first_name = address.get_first_name()?; | ||||
|     Ok(Some(BluesnapCardHolderInfo { | ||||
|         first_name: address.get_first_name()?.clone(), | ||||
|         last_name: address.get_last_name()?.clone(), | ||||
|         first_name: first_name.clone(), | ||||
|         last_name: address.get_last_name().unwrap_or(first_name).clone(), | ||||
|         email, | ||||
|     })) | ||||
| } | ||||
|  | ||||
| @ -784,9 +784,10 @@ fn build_bill_to( | ||||
|         .ok_or_else(utils::missing_field_err("billing.address"))?; | ||||
|     let mut state = address.to_state_code()?.peek().clone(); | ||||
|     state.truncate(20); | ||||
|     let first_name = address.get_first_name()?; | ||||
|     Ok(BillTo { | ||||
|         first_name: address.get_first_name()?.to_owned(), | ||||
|         last_name: address.get_last_name()?.to_owned(), | ||||
|         first_name: first_name.clone(), | ||||
|         last_name: address.get_last_name().unwrap_or(first_name).clone(), | ||||
|         address1: address.get_line1()?.to_owned(), | ||||
|         locality: address.get_city()?.to_owned(), | ||||
|         administrative_area: Secret::from(state), | ||||
|  | ||||
| @ -88,9 +88,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FortePaymentsRequest { | ||||
|                     expire_year: ccard.card_exp_year.clone(), | ||||
|                     card_verification_value: ccard.card_cvc.clone(), | ||||
|                 }; | ||||
|                 let first_name = address.get_first_name()?; | ||||
|                 let billing_address = BillingAddress { | ||||
|                     first_name: address.get_first_name()?.to_owned(), | ||||
|                     last_name: address.get_last_name()?.to_owned(), | ||||
|                     first_name: first_name.clone(), | ||||
|                     last_name: address.get_last_name().unwrap_or(first_name).clone(), | ||||
|                 }; | ||||
|                 let authorization_amount = | ||||
|                     utils::to_currency_base_unit_asf64(item.request.amount, item.request.currency)?; | ||||
|  | ||||
| @ -411,9 +411,13 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> | ||||
|             .address | ||||
|             .as_ref() | ||||
|             .ok_or_else(utils::missing_field_err("billing.address"))?; | ||||
|         let first_name = billing_address.get_first_name()?; | ||||
|         let delivery = DeliveryObject { | ||||
|             first_name: billing_address.get_first_name()?.to_owned(), | ||||
|             last_name: billing_address.get_last_name()?.to_owned(), | ||||
|             first_name: first_name.clone(), | ||||
|             last_name: billing_address | ||||
|                 .get_last_name() | ||||
|                 .unwrap_or(first_name) | ||||
|                 .clone(), | ||||
|             address1: billing_address.get_line1()?.to_owned(), | ||||
|             house_number: billing_address.get_line2()?.to_owned(), | ||||
|             zip_code: billing_address.get_zip()?.to_owned(), | ||||
|  | ||||
| @ -116,14 +116,18 @@ impl TryFrom<&types::PaymentsPreProcessingRouterData> for NmiVaultRequest { | ||||
|         let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?; | ||||
|         let (ccnumber, ccexp, cvv) = get_card_details(item.request.payment_method_data.clone())?; | ||||
|         let billing_details = item.get_billing_address()?; | ||||
|         let first_name = billing_details.get_first_name()?; | ||||
|  | ||||
|         Ok(Self { | ||||
|             security_key: auth_type.api_key, | ||||
|             ccnumber, | ||||
|             ccexp, | ||||
|             cvv, | ||||
|             first_name: billing_details.get_first_name()?.to_owned(), | ||||
|             last_name: billing_details.get_last_name()?.to_owned(), | ||||
|             first_name: first_name.clone(), | ||||
|             last_name: billing_details | ||||
|                 .get_last_name() | ||||
|                 .unwrap_or(first_name) | ||||
|                 .clone(), | ||||
|             address1: billing_details.line1.clone(), | ||||
|             address2: billing_details.line2.clone(), | ||||
|             city: billing_details.city.clone(), | ||||
|  | ||||
| @ -663,10 +663,11 @@ impl<F> | ||||
|             ), | ||||
|             (AlternativePaymentMethodType::Sofort, _) | (AlternativePaymentMethodType::Eps, _) => { | ||||
|                 let address = item.get_billing_address()?; | ||||
|                 let first_name = address.get_first_name()?; | ||||
|                 ( | ||||
|                     Some(BillingAddress { | ||||
|                         first_name: Some(address.get_first_name()?.clone()), | ||||
|                         last_name: Some(address.get_last_name()?.clone()), | ||||
|                         first_name: Some(first_name.clone()), | ||||
|                         last_name: Some(address.get_last_name().unwrap_or(first_name).clone()), | ||||
|                         email: item.request.get_email()?, | ||||
|                         country: item.get_billing_country()?, | ||||
|                     }), | ||||
| @ -678,10 +679,13 @@ impl<F> | ||||
|                 Some(domain::BankRedirectData::Ideal { bank_name, .. }), | ||||
|             ) => { | ||||
|                 let address = item.get_billing_address()?; | ||||
|                 let first_name = address.get_first_name()?.clone(); | ||||
|                 ( | ||||
|                     Some(BillingAddress { | ||||
|                         first_name: Some(address.get_first_name()?.clone()), | ||||
|                         last_name: Some(address.get_last_name()?.clone()), | ||||
|                         first_name: Some(first_name.clone()), | ||||
|                         last_name: Some( | ||||
|                             address.get_last_name().ok().unwrap_or(&first_name).clone(), | ||||
|                         ), | ||||
|                         email: item.request.get_email()?, | ||||
|                         country: item.get_billing_country()?, | ||||
|                     }), | ||||
| @ -715,6 +719,7 @@ fn get_pay_later_info<F>( | ||||
|         .address | ||||
|         .as_ref() | ||||
|         .ok_or_else(utils::missing_field_err("billing.address"))?; | ||||
|     let first_name = address.get_first_name()?; | ||||
|     let payment_method = payment_method_type; | ||||
|     Ok(NuveiPaymentsRequest { | ||||
|         payment_option: PaymentOption { | ||||
| @ -724,8 +729,8 @@ fn get_pay_later_info<F>( | ||||
|             }), | ||||
|             billing_address: Some(BillingAddress { | ||||
|                 email: item.request.get_email()?, | ||||
|                 first_name: Some(address.get_first_name()?.to_owned()), | ||||
|                 last_name: Some(address.get_last_name()?.to_owned()), | ||||
|                 first_name: Some(first_name.clone()), | ||||
|                 last_name: Some(address.get_last_name().unwrap_or(first_name).clone()), | ||||
|                 country: address.get_country()?.to_owned(), | ||||
|             }), | ||||
|             ..Default::default() | ||||
| @ -905,12 +910,15 @@ fn get_card_info<F>( | ||||
|         .and_then(|billing_details| billing_details.address.as_ref()); | ||||
|  | ||||
|     let billing_address = match address { | ||||
|         Some(address) => Some(BillingAddress { | ||||
|             first_name: Some(address.get_first_name()?.clone()), | ||||
|             last_name: Some(address.get_last_name()?.clone()), | ||||
|         Some(address) => { | ||||
|             let first_name = address.get_first_name()?.clone(); | ||||
|             Some(BillingAddress { | ||||
|                 first_name: Some(first_name.clone()), | ||||
|                 last_name: Some(address.get_last_name().ok().unwrap_or(&first_name).clone()), | ||||
|                 email: item.request.get_email()?, | ||||
|                 country: item.get_billing_country()?, | ||||
|         }), | ||||
|             }) | ||||
|         } | ||||
|         None => None, | ||||
|     }; | ||||
|     let (is_rebilling, additional_params, user_token_id) = | ||||
|  | ||||
| @ -1194,7 +1194,12 @@ impl AddressDetailsData for api::AddressDetails { | ||||
|  | ||||
|     fn get_full_name(&self) -> Result<Secret<String>, Error> { | ||||
|         let first_name = self.get_first_name()?.peek().to_owned(); | ||||
|         let last_name = self.get_last_name()?.peek().to_owned(); | ||||
|         let last_name = self | ||||
|             .get_last_name() | ||||
|             .ok() | ||||
|             .cloned() | ||||
|             .unwrap_or(Secret::new("".to_string())); | ||||
|         let last_name = last_name.peek(); | ||||
|         let full_name = format!("{} {}", first_name, last_name).trim().to_string(); | ||||
|         Ok(Secret::new(full_name)) | ||||
|     } | ||||
|  | ||||
| @ -98,10 +98,11 @@ impl TryFrom<&VoltRouterData<&types::PaymentsAuthorizeRouterData>> for VoltPayme | ||||
|                     let payment_pending_url = item.router_data.request.router_return_url.clone(); | ||||
|                     let payment_cancel_url = item.router_data.request.router_return_url.clone(); | ||||
|                     let address = item.router_data.get_billing_address()?; | ||||
|                     let first_name = address.get_first_name()?; | ||||
|                     let shopper = ShopperDetails { | ||||
|                         email: item.router_data.request.email.clone(), | ||||
|                         first_name: address.get_first_name()?.to_owned(), | ||||
|                         last_name: address.get_last_name()?.to_owned(), | ||||
|                         first_name: first_name.to_owned(), | ||||
|                         last_name: address.get_last_name().unwrap_or(first_name).to_owned(), | ||||
|                         reference: item.router_data.get_customer_id()?.to_owned(), | ||||
|                     }; | ||||
|                     let transaction_type = TransactionType::Services; //transaction_type is a form of enum, it is pre defined and value for this can not be taken from user so we are keeping it as Services as this transaction is type of service. | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Narayan Bhat
					Narayan Bhat