Skip to content

Commit 7abd151

Browse files
authored
fix(connectors): [fiuu] zero amount mandate flow for wallets (#7261)
1 parent 3aa910e commit 7abd151

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use strum::Display;
2828
use crate::{
2929
types::{RefundsResponseRouterData, ResponseRouterData},
3030
utils::{
31-
self, AddressDetailsData, ApplePay, PaymentsAuthorizeRequestData,
31+
self, AddressData, AddressDetailsData, ApplePay, PaymentsAuthorizeRequestData,
3232
PaymentsCancelRequestData, PaymentsCaptureRequestData, PaymentsSetupMandateRequestData,
3333
PaymentsSyncRequestData, RefundsRequestData, RouterData as _,
3434
},
@@ -1467,7 +1467,7 @@ impl TryFrom<&SetupMandateRouterData> for NovalnetPaymentsRequest {
14671467
enums::AuthenticationType::NoThreeDs => None,
14681468
};
14691469
let test_mode = get_test_mode(item.test_mode);
1470-
let req_address = item.get_billing_address()?.to_owned();
1470+
let req_address = item.get_optional_billing();
14711471

14721472
let billing = NovalnetPaymentsRequestBilling {
14731473
house_no: item.get_optional_billing_line1(),
@@ -1477,10 +1477,12 @@ impl TryFrom<&SetupMandateRouterData> for NovalnetPaymentsRequest {
14771477
country_code: item.get_optional_billing_country(),
14781478
};
14791479

1480+
let email = item.get_billing_email().or(item.request.get_email())?;
1481+
14801482
let customer = NovalnetPaymentsRequestCustomer {
1481-
first_name: req_address.get_optional_first_name(),
1482-
last_name: req_address.get_optional_last_name(),
1483-
email: item.request.get_email()?.clone(),
1483+
first_name: req_address.and_then(|addr| addr.get_optional_first_name()),
1484+
last_name: req_address.and_then(|addr| addr.get_optional_last_name()),
1485+
email,
14841486
mobile: item.get_optional_billing_phone_number(),
14851487
billing: Some(billing),
14861488
// no_nc is used to indicate if minimal customer data is passed or not
@@ -1504,7 +1506,7 @@ impl TryFrom<&SetupMandateRouterData> for NovalnetPaymentsRequest {
15041506
card_expiry_month: req_card.card_exp_month.clone(),
15051507
card_expiry_year: req_card.card_exp_year.clone(),
15061508
card_cvc: req_card.card_cvc.clone(),
1507-
card_holder: req_address.get_full_name()?.clone(),
1509+
card_holder: item.get_billing_address()?.get_full_name()?,
15081510
});
15091511

15101512
let transaction = NovalnetPaymentsRequestTransaction {

crates/hyperswitch_connectors/src/utils.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,8 @@ pub trait AddressData {
19351935
fn get_optional_full_name(&self) -> Option<Secret<String>>;
19361936
fn get_email(&self) -> Result<Email, Error>;
19371937
fn get_phone_with_country_code(&self) -> Result<Secret<String>, Error>;
1938+
fn get_optional_first_name(&self) -> Option<Secret<String>>;
1939+
fn get_optional_last_name(&self) -> Option<Secret<String>>;
19381940
}
19391941

19401942
impl AddressData for Address {
@@ -1955,6 +1957,18 @@ impl AddressData for Address {
19551957
.transpose()?
19561958
.ok_or_else(missing_field_err("phone"))
19571959
}
1960+
1961+
fn get_optional_first_name(&self) -> Option<Secret<String>> {
1962+
self.address
1963+
.as_ref()
1964+
.and_then(|billing_address| billing_address.get_optional_first_name())
1965+
}
1966+
1967+
fn get_optional_last_name(&self) -> Option<Secret<String>> {
1968+
self.address
1969+
.as_ref()
1970+
.and_then(|billing_address| billing_address.get_optional_last_name())
1971+
}
19581972
}
19591973
pub trait PaymentsPreProcessingRequestData {
19601974
fn get_redirect_response_payload(&self) -> Result<pii::SecretSerdeValue, Error>;

0 commit comments

Comments
 (0)