feat(connector): [Checkout] Add Google Pay Predecrypt Flow#9130
feat(connector): [Checkout] Add Google Pay Predecrypt Flow#9130likhinbopanna merged 14 commits intomainfrom
Conversation
Changed Files
|
| expiry_month: Secret<String>, | ||
| expiry_year: Secret<String>, | ||
| eci: Option<String>, | ||
| cryptogram: Secret<String>, |
There was a problem hiding this comment.
why cryptogram is mandatory? it might not be present in a decrypted token
There was a problem hiding this comment.
Made it an option.
crates/router/src/core/payments.rs
Outdated
| ) => !matches!( | ||
| google_pay_pre_decrypt_flow_filter, | ||
| Some(GooglePayPreDecryptFlow::NetworkTokenization) | ||
| ), |
There was a problem hiding this comment.
instead of not operation over network tokenization, can we just do a match over connector tokenization. if tomorrow a new variant comes it, that is not needed to be handled in this function
crates/router/src/core/payments.rs
Outdated
| google_pay_pre_decrypt_flow_filter, | ||
| Some(GooglePayPreDecryptFlow::NetworkTokenization) | ||
| ), | ||
| _ => true, |
There was a problem hiding this comment.
dont use a wildcard matching, explicitly put all the cases or you can use a if let statement in this case
| PaymentMethodToken::GooglePayDecrypt(google_pay_decrypted_data) => { | ||
| let token = google_pay_decrypted_data | ||
| .application_primary_account_number | ||
| .clone(); | ||
| let expiry_month = google_pay_decrypted_data | ||
| .get_expiry_month() | ||
| .change_context(errors::ConnectorError::InvalidDataFormat { | ||
| field_name: "payment_method_data.card.card_exp_month", | ||
| })?; | ||
| let expiry_year = google_pay_decrypted_data | ||
| .get_four_digit_expiry_year() | ||
| .change_context(errors::ConnectorError::InvalidDataFormat { | ||
| field_name: "payment_method_data.card.card_exp_year", | ||
| })?; | ||
| let cryptogram = | ||
| Some(google_pay_decrypted_data.cryptogram.clone().ok_or_else( | ||
| || errors::ConnectorError::MissingRequiredField { | ||
| field_name: "cryptogram", | ||
| }, | ||
| )?); | ||
| Ok(PaymentSource::GooglePayPredecrypt(Box::new( | ||
| GooglePayPredecrypt { | ||
| _type: "network_token".to_string(), | ||
| token, | ||
| token_type: "googlepay".to_string(), | ||
| expiry_month, | ||
| expiry_year, | ||
| eci: Some("06".to_string()), | ||
| cryptogram, | ||
| }, | ||
| ))) | ||
| } |
There was a problem hiding this comment.
nit: you can further break it down to try_from
| Some(GooglePayPreDecryptFlow::ConnectorTokenization) | ||
| ) | ||
| } else { | ||
| true |
There was a problem hiding this comment.
nit: add comment why this should be true
| token_type: "googlepay".to_string(), | ||
| expiry_month, | ||
| expiry_year, | ||
| eci: Some("06".to_string()), |
There was a problem hiding this comment.
Why are we hardcoding here ?
df767ad to
7235677
Compare
7235677 to
9335637
Compare
9accaba to
9335637
Compare
crates/router/src/core/payments.rs
Outdated
| matches!( | ||
| google_pay_pre_decrypt_flow_filter, | ||
| Some(GooglePayPreDecryptFlow::ConnectorTokenization) | ||
| ) |
There was a problem hiding this comment.
Won't this logic affect other connectors that have a Google Pay decrypt flow?
If the connector and payment method are added under the tokenization environment config, it implies that we should follow connector tokenization for that specific connector and payment method combination.
For example:
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization" }
This means: follow connector tokenization for all wallet payment methods under the checkout connector.
If the goal is to skip connector tokenization for a specific wallet flow, we explicitly set the value as network_tokenization. If it is not specified, or if it is set as connector_tokenization, we follow the default connector tokenization behavior. We usually don’t explicitly specify connector_tokenization, because the absence of a network_tokenization override already implies it.
But according to the above match statement the logic only triggers the connector tokenization flow if the environment explicitly specifies connector_tokenization. Ideally, this should also include the case when the value is None, i.e., either it's not present or explicitly set as connector_tokenization — both should lead to connector tokenization being followed.
In simpler terms, we should only skip connector tokenization if the env value is explicitly network_tokenization. Otherwise (if it's None or connector_tokenization), we should proceed with connector tokenization.
There was a problem hiding this comment.
Sure, reverting the change.
| [tokenization] | ||
| stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { type = "disable_only", list = "google_pay" } } | ||
| checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization" } | ||
| checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization", google_pay_pre_decrypt_flow = "network_tokenization" } |
There was a problem hiding this comment.
Should we move the logic of determining the flow of payment method type for a connector—based on the payment method data—to the ConnectorSpecifications trait?
cc: @jarnura
There was a problem hiding this comment.
yes, ConnectorSpecification is the way-forward to go.
There was a problem hiding this comment.
Sure, taking this in a separate PR.
There was a problem hiding this comment.
Please create an issue for this
77d10a4 to
d6dea05
Compare
ShankarSinghC
left a comment
There was a problem hiding this comment.
The changes LGTM
As this is the core flow change test google pay payment for few prod connectors as well
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local> Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
fdd8a6a
…pay-new-field * 'main' of github.com:juspay/hyperswitch: (21 commits) feat(payments): add tokenization action handling to payment flow for braintree (#9506) feat(connector): [Loonio] Add template code (#9586) fix(connector): [paysafe] make `eci_indicator` field optional (#9591) fix(core): add should_call_connector_customer function to connector specification (#9569) feat(ucs): Add profile ID to lineage tracking in Unified Connector Service (#9559) feat(core): Add support for partial auth in proxy payments [V2] (#9503) chore(version): 2025.09.30.0 fix(authorizedotnet): refund via ucs missing connector_metadata (#9581) feat(auth): add new authentication to communicate between microservices (#9547) Fix: Ideal Giropay Country Currency Config (#9552) feat(connector): [ACI] cypress added (#9502) feat(connector): Add Peachpayments Cypress (#9573) chore(version): 2025.09.29.0 feat(finix): template code (#9557) feat(cypress): add cypress test-cases for manual retry (#9505) feat(core): update additional payment method data in psync response (#9519) feat(connector): [Checkout] Add Google Pay Predecrypt Flow (#9130) feat(framework): Added smithy, smithy-core and smithy-generator crates (#9249) fix(core): add request_extended_authorization in the payment attempt and populate it in the payment response (#9492) chore(version): 2025.09.26.0 ...
Type of Change
Closes this issue
Description
Added Google Pay Predecrypt Flow
Additional Changes
Motivation and Context
How did you test it?
Request:
Response:
Request:
Response:
Checklist
cargo +nightly fmt --allcargo clippy