Skip to content

Commit

Permalink
refactor: resolve comments(part2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakilmostak committed Feb 3, 2025
1 parent 20386bd commit f6145db
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 88 deletions.
4 changes: 2 additions & 2 deletions crates/cards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'de> Deserialize<'de> for CardSecurityCode {
}
}

#[derive(Serialize)]
#[derive(Clone, Debug, Serialize)]
pub struct CardExpirationMonth(StrongSecret<u8>);

impl CardExpirationMonth {
Expand Down Expand Up @@ -67,7 +67,7 @@ impl<'de> Deserialize<'de> for CardExpirationMonth {
}
}

#[derive(Serialize)]
#[derive(Clone, Debug, Serialize)]
pub struct CardExpirationYear(StrongSecret<u16>);

impl CardExpirationYear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1775,22 +1775,25 @@ impl
let payment_information =
PaymentInformation::GooglePay(Box::new(GooglePayPaymentInformation {
tokenized_card: TokenizedCard {
number: google_pay_decrypted_data.payment_method_details.pan,
number: Secret::new(
google_pay_decrypted_data
.payment_method_details
.pan
.get_card_no(),
),
cryptogram: google_pay_decrypted_data.payment_method_details.cryptogram,
transaction_type: TransactionType::GooglePay,
expiration_year: Secret::new(
google_pay_decrypted_data
.payment_method_details
.expiration_year
.expose()
.to_string(),
.four_digits(),
),
expiration_month: Secret::new(
google_pay_decrypted_data
.payment_method_details
.expiration_month
.expose()
.to_string(),
.two_digits(),
),
},
}));
Expand Down
6 changes: 3 additions & 3 deletions crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ pub struct GooglePayDecryptedData {
#[serde(rename_all = "camelCase")]
pub struct GooglePayPaymentMethodDetails {
pub auth_method: common_enums::enums::GooglePayAuthMethod,
pub expiration_month: Secret<u16>,
pub expiration_year: Secret<u16>,
pub pan: Secret<String>,
pub expiration_month: cards::CardExpirationMonth,
pub expiration_year: cards::CardExpirationYear,
pub pan: cards::CardNumber,
pub cryptogram: Option<Secret<String>>,
pub eci_indicator: Option<String>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ encoding_rs = "0.8.33"
error-stack = "0.4.1"
futures = "0.3.30"
hex = "0.4.3"
rust_hkdf = { package = "hkdf", version = "0.12.4" }
hkdf = "0.12.4"
http = "0.2.12"
hyper = "0.14.28"
infer = "0.15.0"
Expand Down
9 changes: 2 additions & 7 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3106,13 +3106,8 @@ where
};

let google_pay_predecrypt = google_pay_data
.parse_value::<hyperswitch_domain_models::router_data::GooglePayDecryptedData>(
"GooglePayDecryptedData",
)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable(
"failed to parse decrypted google pay response to GooglePayDecryptedData",
)?;
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed to get GooglePayDecryptedData in response")?;

Ok(Some(PaymentMethodToken::GooglePayDecrypt(Box::new(
google_pay_predecrypt,
Expand Down
Loading

0 comments on commit f6145db

Please sign in to comment.