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

feat(pm_list): add required fields for giropay #3194

Merged
merged 42 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bd1c1dc
add dynamic fields for sofort aci
AkshayaFoiger Dec 21, 2023
b3d0f99
add dynamic field changes for sofort aci
AkshayaFoiger Dec 21, 2023
dd67fee
add dynamic field changes for sofort aci
AkshayaFoiger Dec 21, 2023
0bd5824
add globalpay and mollie dynamic fields for sofort
AkshayaFoiger Dec 21, 2023
588c6b3
add dynamic fields for sofort
AkshayaFoiger Dec 21, 2023
8679744
chore: run formatter
hyperswitch-bot[bot] Dec 21, 2023
eb36df4
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Dec 21, 2023
289503c
add dynamic fields for aci and adyen giropay
AkshayaFoiger Dec 21, 2023
333ee50
add dynamic fields for giropay
AkshayaFoiger Dec 21, 2023
2bfb7ba
chore: run formatter
hyperswitch-bot[bot] Dec 21, 2023
701affa
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Dec 21, 2023
e790955
add mandate req field for stripe sofort
AkshayaFoiger Jan 1, 2024
678eb53
chore: run formatter
hyperswitch-bot[bot] Jan 1, 2024
4c4e0c0
Merge branch 'main' into dynamic_field/sofort
AkshayaFoiger Jan 9, 2024
bd59a2e
make fields manditory
AkshayaFoiger Jan 9, 2024
3f52d5f
Merge branch 'main' into dynamic_field/sofort
AkshayaFoiger Jan 11, 2024
51fc9a0
add mandate config and refactor stripe sofort
AkshayaFoiger Jan 11, 2024
4737bf5
refactor stripe transformer
AkshayaFoiger Jan 11, 2024
8749233
remove extra field
AkshayaFoiger Jan 11, 2024
28cb2cd
correct field path
AkshayaFoiger Jan 11, 2024
17ee23d
Update crates/router/src/connector/paypal/transformers.rs
AkshayaFoiger Jan 12, 2024
9bc80d4
Merge branch 'main' into dynamic_field/sofort
AkshayaFoiger Jan 12, 2024
1b7c138
fix clippy error
AkshayaFoiger Jan 12, 2024
2bc92a4
fix clippy error
AkshayaFoiger Jan 17, 2024
1717524
chore: run formatter
hyperswitch-bot[bot] Jan 17, 2024
6d65743
resolve comment: make stripe country req
AkshayaFoiger Jan 18, 2024
cb87d75
Update crates/router/src/configs/defaults.rs
AkshayaFoiger Jan 18, 2024
ea7eb37
add comment
AkshayaFoiger Jan 18, 2024
9c0af54
add re field for stripe
AkshayaFoiger Jan 18, 2024
5821804
chore: run formatter
hyperswitch-bot[bot] Jan 18, 2024
ab92bbf
resolve comment
AkshayaFoiger Jan 18, 2024
b5b9fc7
update default.rs
AkshayaFoiger Jan 18, 2024
29c16bd
Merge branch 'dynamic_field/sofort' into dynamic_field/giropay
AkshayaFoiger Jan 18, 2024
3a3585d
chore: run formatter
hyperswitch-bot[bot] Jan 18, 2024
c0ccd99
Merge branch 'main' into dynamic_field/sofort
AkshayaFoiger Jan 25, 2024
f8f868d
make aci country a mandatory field
AkshayaFoiger Jan 29, 2024
bdf11fc
refactor giropay required fields
AkshayaFoiger Jan 29, 2024
f87f157
Merge branch 'dynamic_field/sofort' into dynamic_field/giropay
AkshayaFoiger Jan 29, 2024
845121c
add configs
AkshayaFoiger Jan 29, 2024
d988c81
Merge branch 'main' into dynamic_field/giropay
AkshayaFoiger Jan 31, 2024
d740753
Merge branch 'main' into dynamic_field/giropay
AkshayaFoiger Feb 1, 2024
457bb72
correct the typo
AkshayaFoiger Feb 2, 2024
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
8 changes: 4 additions & 4 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ pub enum BankRedirectData {
},
Giropay {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
billing_details: Option<BankRedirectBilling>,
/// Bank account details for Giropay

#[schema(value_type = Option<String>)]
Expand Down Expand Up @@ -1258,15 +1258,15 @@ pub enum BankRedirectData {
},
Sofort {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
billing_details: Option<BankRedirectBilling>,

/// The country for bank payment
#[schema(value_type = CountryAlpha2, example = "US")]
country: api_enums::CountryAlpha2,
country: Option<api_enums::CountryAlpha2>,

/// The preferred language
#[schema(example = "en")]
preferred_language: String,
preferred_language: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have changes for Sofort pm type in this pr? I observed there was another PR for sofort, please undo these changes if not necessary

Copy link
Contributor Author

@AkshayaFoiger AkshayaFoiger Dec 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is another separate PR for Sofort. Sofort changes appeared in this branch as dynamic_field/giropay branch is built upon dynamic_field/sofort branch whilst the PR pointed to main.
Now Sofort changes are removed. Requesting your review

},
Trustly {
/// The country for bank payment
Expand Down
520 changes: 519 additions & 1 deletion crates/router/src/configs/defaults.rs

Large diffs are not rendered by default.

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 @@ -190,7 +190,7 @@ impl
api_models::payments::BankRedirectData::Sofort { country, .. } => {
Self::BankRedirect(Box::new(BankRedirectionPMData {
payment_brand: PaymentBrand::Sofortueberweisung,
bank_account_country: Some(country.to_owned()),
bank_account_country: country.to_owned(),
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
Expand Down
5 changes: 1 addition & 4 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2743,10 +2743,7 @@ fn get_redirect_extra_details(
country,
preferred_language,
..
} => Ok((
Some(preferred_language.to_string()),
Some(country.to_owned()),
)),
} => Ok((preferred_language.clone(), country.clone())),
api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => {
let country = country.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "country",
Expand Down
18 changes: 15 additions & 3 deletions crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ fn get_payment_source(
country,
..
} => Ok(PaymentSourceItem::Giropay(RedirectRequest {
name: billing_details.get_billing_name()?,
name: billing_details
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "giropay.billing_details",
})?
.get_billing_name()?,
country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "giropay.country",
})?,
Expand Down Expand Up @@ -350,8 +355,15 @@ fn get_payment_source(
preferred_language: _,
billing_details,
} => Ok(PaymentSourceItem::Sofort(RedirectRequest {
name: billing_details.get_billing_name()?,
country_code: *country,
name: billing_details
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "sofort.billing_details",
})?
.get_billing_name()?,
country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "country",
})?,
experience_context: ContextStruct {
return_url: item.request.complete_authorize_url.clone(),
cancel_url: item.request.complete_authorize_url.clone(),
Expand Down
29 changes: 24 additions & 5 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,13 @@ impl TryFrom<&payments::BankRedirectData> for StripeBillingAddress {
payments::BankRedirectData::Giropay {
billing_details, ..
} => Ok(Self {
name: billing_details.billing_name.clone(),
name: billing_details
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "giropay.billing_details",
})?
.billing_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is billing_name mandatory?
if yes, please use get_billing_name() method from utils to throw the error.

.clone(),
..Self::default()
}),
payments::BankRedirectData::Ideal {
Expand Down Expand Up @@ -1145,8 +1151,12 @@ impl TryFrom<&payments::BankRedirectData> for StripeBillingAddress {
payments::BankRedirectData::Sofort {
billing_details, ..
} => Ok(Self {
name: billing_details.billing_name.clone(),
email: billing_details.email.clone(),
name: billing_details
.clone()
.and_then(|billing_data| billing_data.billing_name.clone()),
email: billing_details
.clone()
.and_then(|billing_data| billing_data.email.clone()),
..Self::default()
}),
payments::BankRedirectData::Bizum {}
Expand Down Expand Up @@ -1631,8 +1641,17 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData {
} => Ok(Self::BankRedirect(StripeBankRedirectData::StripeSofort(
Box::new(StripeSofort {
payment_method_data_type,
country: country.to_owned(),
preferred_language: preferred_language.to_owned(),
country: country
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "country",
})?
.to_owned(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add utils function get_billing_country for BankRedirectBilling and reuse this function in other places as well

preferred_language: preferred_language
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "sofort.preferred_language",
})?
.to_owned(),
}),
))),
payments::BankRedirectData::OnlineBankingFpx { .. } => {
Expand Down
13 changes: 9 additions & 4 deletions crates/router/src/connector/worldline/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,16 @@ fn make_bank_redirect_request(
{
PaymentMethodSpecificData::PaymentProduct816SpecificInput(Box::new(Giropay {
bank_account_iban: BankAccountIban {
account_holder_name: billing_details.billing_name.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
account_holder_name: billing_details
.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "giropay.billing_details",
})?
.billing_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the utils method - get_billing_name() here

.clone()
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "billing_details.billing_name",
},
)?,
})?,
iban: bank_account_iban.clone(),
},
}))
Expand Down
22 changes: 15 additions & 7 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3440,12 +3440,16 @@
"giropay": {
"type": "object",
"required": [
"billing_details",
"country"
],
"properties": {
"billing_details": {
"$ref": "#/components/schemas/BankRedirectBilling"
"allOf": [
{
"$ref": "#/components/schemas/BankRedirectBilling"
}
],
"nullable": true
},
"bank_account_bic": {
"type": "string",
Expand Down Expand Up @@ -3648,21 +3652,25 @@
"sofort": {
"type": "object",
"required": [
"billing_details",
"country",
"preferred_language"
"country"
],
"properties": {
"billing_details": {
"$ref": "#/components/schemas/BankRedirectBilling"
"allOf": [
{
"$ref": "#/components/schemas/BankRedirectBilling"
}
],
"nullable": true
},
"country": {
"$ref": "#/components/schemas/CountryAlpha2"
},
"preferred_language": {
"type": "string",
"description": "The preferred language",
"example": "en"
"example": "en",
"nullable": true
}
}
}
Expand Down
Loading