Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(payment_methods): make the card_holder_name as an empty string if not sent #3173

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/router/src/connector/aci/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl TryFrom<api_models::payments::Card> for PaymentDetails {
card_number: card_data.card_number,
card_holder: card_data
.card_holder_name
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
card_expiry_month: card_data.card_exp_month,
card_expiry_year: card_data.card_exp_year,
card_cvv: card_data.card_cvc,
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/bambora/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use masking::{PeekInterface, Secret};
use serde::{Deserialize, Deserializer, Serialize};

use crate::{
connector::utils::{self, BrowserInformationData, PaymentsAuthorizeRequestData},
connector::utils::{BrowserInformationData, PaymentsAuthorizeRequestData},
consts,
core::errors,
services,
Expand Down Expand Up @@ -119,7 +119,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BamboraPaymentsRequest {
let bambora_card = BamboraCard {
name: req_card
.card_holder_name
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number: req_card.card_number,
expiry_month: req_card.card_exp_month,
expiry_year: req_card.card_exp_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ impl TryFrom<&types::TokenizationRouterData> for BraintreeTokenRequest {
cvv: card_data.card_cvc,
cardholder_name: card_data
.card_holder_name
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
},
};
Ok(Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/dlocal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
use url::Url;

use crate::{
connector::utils::{self, AddressDetailsData, PaymentsAuthorizeRequestData, RouterData},
connector::utils::{AddressDetailsData, PaymentsAuthorizeRequestData, RouterData},
core::errors,
services,
types::{self, api, storage::enums},
Expand Down Expand Up @@ -128,7 +128,7 @@ impl TryFrom<&DlocalRouterData<&types::PaymentsAuthorizeRouterData>> for DlocalP
holder_name: ccard
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number: ccard.card_number.clone(),
cvv: ccard.card_cvc.clone(),
expiration_month: ccard.card_exp_month.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use serde::{Deserialize, Serialize};
use url::Url;

use crate::{
connector::utils,
core::errors,
services,
types::{self, api, storage::enums},
Expand Down Expand Up @@ -90,7 +89,7 @@ impl TryFrom<api_models::payments::Card> for DummyConnectorCard {
Ok(Self {
name: value
.card_holder_name
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number: value.card_number,
expiry_month: value.card_exp_month,
expiry_year: value.card_exp_year,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/forte/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FortePaymentsRequest {
name_on_card: ccard
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
account_number: ccard.card_number.clone(),
expire_month: ccard.card_exp_month.clone(),
expire_year: ccard.card_exp_year.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/mollie/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl TryFrom<&types::TokenizationRouterData> for MollieCardTokenRequest {
let card_holder = ccard
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?;
.unwrap_or(Secret::new("".to_string()));
let card_number = ccard.card_number.clone();
let card_expiry_date =
ccard.get_card_expiry_month_year_2_digit_with_delimiter("/".to_owned());
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/noon/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest {
name_on_card: req_card
.card_holder_name
.clone()
.ok_or_else(conn_utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number_plain: req_card.card_number.clone(),
expiry_month: req_card.card_exp_month.clone(),
expiry_year: req_card.get_expiry_year_4_digit(),
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/opayo/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for OpayoPaymentsRequest {
let card = OpayoCard {
name: req_card
.card_holder_name
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number: req_card.card_number,
expiry_month: req_card.card_exp_month,
expiry_year: req_card.card_exp_year,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/payeezy/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn get_payment_method_data(
cardholder_name: card
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
card_number: card.card_number.clone(),
exp_date: card.get_card_expiry_month_year_2_digit_with_delimiter("".to_string()),
cvv: card.card_cvc.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP
name: ccard
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
number: Some(ccard.card_number.clone()),
security_code: Some(ccard.card_cvc.clone()),
attributes,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/powertranz/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl TryFrom<&Card> for Source {
cardholder_name: card
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
card_pan: card.card_number.clone(),
card_expiration: card.get_expiry_date_as_yymm(),
card_cvv: card.card_cvc.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/rapyd/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use time::PrimitiveDateTime;
use url::Url;

use crate::{
connector::utils::{self, PaymentsAuthorizeRequestData},
connector::utils::PaymentsAuthorizeRequestData,
consts,
core::errors,
pii::Secret,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay
name: ccard
.card_holder_name
.to_owned()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
cvv: ccard.card_cvc.to_owned(),
}),
address: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/shift4/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl<T>
cardholder_name: card
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
};
if item.is_three_ds() {
Ok(Self::Cards3DSRequest(Box::new(Cards3DSRequest {
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/stax/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl TryFrom<&types::TokenizationRouterData> for StaxTokenRequest {
.get_card_expiry_month_year_2_digit_with_delimiter("".to_string()),
person_name: card_data
.card_holder_name
.ok_or_else(missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
card_number: card_data.card_number,
card_cvv: card_data.card_cvc,
customer_id: Secret::new(customer_id),
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/worldline/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fn make_card_request(
cardholder_name: ccard
.card_holder_name
.clone()
.ok_or_else(utils::missing_field_err("card_holder_name"))?,
.unwrap_or(Secret::new("".to_string())),
cvv: ccard.card_cvc.clone(),
expiry_date,
};
Expand Down
Loading