Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(store): store id for adyen (#10108)

Nithin N1895e4129c99
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index cc636f8ad2..be9e15d135 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -297,6 +297,7 @@ pub struct AdyenPaymentRequest<'a> {
channel: Option<Channel>,
merchant_order_reference: Option<String>,
splits: Option<Vec<AdyenSplitData>>,
+ /// metadata.store
store: Option<String>,
device_fingerprint: Option<Secret<String>>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
@@ -1415,6 +1416,7 @@ pub struct AdyenRefundRequest {
merchant_refund_reason: Option<AdyenRefundRequestReason>,
reference: String,
splits: Option<Vec<AdyenSplitData>>,
+ /// refund_connector_metadata.store
store: Option<String>,
}
@@ -2841,6 +2843,12 @@ fn get_device_fingerprint(metadata: serde_json::Value) -> Option<Secret<String>>
.map(|fingerprint| Secret::new(fingerprint.to_string()))
}
+fn get_store_id(metadata: serde_json::Value) -> Option<String> {
+ metadata
+ .get("store")
+ .and_then(|store| store.as_str())
+ .map(|store| store.to_string())
+}
impl
TryFrom<(
&AdyenRouterData<&PaymentsAuthorizeRouterData>,
@@ -2998,7 +3006,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3085,7 +3100,14 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &Card)> for AdyenP
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3166,7 +3188,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3251,7 +3280,14 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &VoucherData)>
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3328,7 +3364,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3446,7 +3489,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3531,7 +3581,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
.router_data
@@ -3662,7 +3719,14 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &WalletData)>
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
@@ -3758,7 +3822,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
.router_data
@@ -3838,7 +3909,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
.router_data
@@ -5038,7 +5116,14 @@ impl<F> TryFrom<&AdyenRouterData<&RefundsRouterData<F>>> for AdyenRefundRequest
.as_ref()
{
Some(hyperswitch_domain_models::router_request_types::SplitRefundsRequest::AdyenSplitRefund(adyen_split_data)) => get_adyen_split_request(adyen_split_data, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .refund_connector_metadata
+ .clone()
+ .and_then(|metadata| get_store_id(metadata.expose())),
+ None,
+ ),
};
Ok(Self {
@@ -6392,7 +6477,14 @@ impl
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
- _ => (None, None),
+ _ => (
+ item.router_data
+ .request
+ .metadata
+ .clone()
+ .and_then(get_store_id),
+ None,
+ ),
};
let device_fingerprint = item
.router_data