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(compatibility): add straight through routing and udf mapping in setup intent #1536

Merged
merged 2 commits into from
Jul 3, 2023
Merged
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
16 changes: 16 additions & 0 deletions crates/router/src/compatibility/stripe/setup_intents/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl From<Shipping> for payments::Address {
pub struct StripeSetupIntentRequest {
pub confirm: Option<bool>,
pub customer: Option<String>,
pub connector: Option<Vec<api_enums::RoutableConnectors>>,
pub description: Option<String>,
pub currency: Option<String>,
pub payment_method_data: Option<StripePaymentMethodData>,
Expand Down Expand Up @@ -165,6 +166,18 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
}
None => (None, None),
};
let routable_connector: Option<api_enums::RoutableConnectors> =
item.connector.and_then(|v| v.into_iter().next());

let routing = routable_connector
.map(api_types::RoutingAlgorithm::Single)
.map(|r| {
serde_json::to_value(r)
.into_report()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("converting to routing failed")
})
.transpose()?;
let ip_address = item
.receipt_ipaddress
.map(|ip| std::net::IpAddr::from_str(ip.as_str()))
Expand Down Expand Up @@ -228,6 +241,7 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
setup_future_usage: item.setup_future_usage,
merchant_connector_details: item.merchant_connector_details,
authentication_type,
routing,
mandate_data: mandate_options,
browser_info: Some(
serde_json::to_value(crate::types::BrowserInformation {
Expand Down Expand Up @@ -360,6 +374,7 @@ pub struct StripeSetupIntentResponse {
pub object: String,
pub status: StripeSetupStatus,
pub client_secret: Option<masking::Secret<String>>,
pub metadata: Option<secret::SecretSerdeValue>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<time::PrimitiveDateTime>,
pub customer: Option<String>,
Expand Down Expand Up @@ -403,6 +418,7 @@ impl From<payments::PaymentsResponse> for StripeSetupIntentResponse {
charges: payment_intent::Charges::new(),
created: resp.created,
customer: resp.customer_id,
metadata: resp.udf,
id: resp.payment_id,
refunds: resp
.refunds
Expand Down