mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
feat(compatibility): add straight through routing and udf mapping in setup intent (#1536)
Co-authored-by: Sahkal Poddar <sahkal.poddar@juspay.in>
This commit is contained in:
@ -125,6 +125,7 @@ impl From<Shipping> for payments::Address {
|
|||||||
pub struct StripeSetupIntentRequest {
|
pub struct StripeSetupIntentRequest {
|
||||||
pub confirm: Option<bool>,
|
pub confirm: Option<bool>,
|
||||||
pub customer: Option<String>,
|
pub customer: Option<String>,
|
||||||
|
pub connector: Option<Vec<api_enums::RoutableConnectors>>,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub currency: Option<String>,
|
pub currency: Option<String>,
|
||||||
pub payment_method_data: Option<StripePaymentMethodData>,
|
pub payment_method_data: Option<StripePaymentMethodData>,
|
||||||
@ -165,6 +166,18 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
|
|||||||
}
|
}
|
||||||
None => (None, None),
|
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
|
let ip_address = item
|
||||||
.receipt_ipaddress
|
.receipt_ipaddress
|
||||||
.map(|ip| std::net::IpAddr::from_str(ip.as_str()))
|
.map(|ip| std::net::IpAddr::from_str(ip.as_str()))
|
||||||
@ -228,6 +241,7 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
|
|||||||
setup_future_usage: item.setup_future_usage,
|
setup_future_usage: item.setup_future_usage,
|
||||||
merchant_connector_details: item.merchant_connector_details,
|
merchant_connector_details: item.merchant_connector_details,
|
||||||
authentication_type,
|
authentication_type,
|
||||||
|
routing,
|
||||||
mandate_data: mandate_options,
|
mandate_data: mandate_options,
|
||||||
browser_info: Some(
|
browser_info: Some(
|
||||||
serde_json::to_value(crate::types::BrowserInformation {
|
serde_json::to_value(crate::types::BrowserInformation {
|
||||||
@ -360,6 +374,7 @@ pub struct StripeSetupIntentResponse {
|
|||||||
pub object: String,
|
pub object: String,
|
||||||
pub status: StripeSetupStatus,
|
pub status: StripeSetupStatus,
|
||||||
pub client_secret: Option<masking::Secret<String>>,
|
pub client_secret: Option<masking::Secret<String>>,
|
||||||
|
pub metadata: Option<secret::SecretSerdeValue>,
|
||||||
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
#[serde(with = "common_utils::custom_serde::iso8601::option")]
|
||||||
pub created: Option<time::PrimitiveDateTime>,
|
pub created: Option<time::PrimitiveDateTime>,
|
||||||
pub customer: Option<String>,
|
pub customer: Option<String>,
|
||||||
@ -403,6 +418,7 @@ impl From<payments::PaymentsResponse> for StripeSetupIntentResponse {
|
|||||||
charges: payment_intent::Charges::new(),
|
charges: payment_intent::Charges::new(),
|
||||||
created: resp.created,
|
created: resp.created,
|
||||||
customer: resp.customer_id,
|
customer: resp.customer_id,
|
||||||
|
metadata: resp.udf,
|
||||||
id: resp.payment_id,
|
id: resp.payment_id,
|
||||||
refunds: resp
|
refunds: resp
|
||||||
.refunds
|
.refunds
|
||||||
|
|||||||
Reference in New Issue
Block a user