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(router): Return payment_experience in PML for payment (v2) (#8255)

Anurag Thakur9ce3d73e53c1
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index 26cde7c6c2..c68771b717 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -21693,6 +21693,14 @@
"payment_method_subtype": {
"$ref": "#/components/schemas/PaymentMethodType"
},
+ "payment_experience": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PaymentExperience"
+ }
+ ],
+ "nullable": true
+ },
"required_fields": {
"allOf": [
{
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 7ab8bc1936..adbfb56c0f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -7605,6 +7605,10 @@ pub struct ResponsePaymentMethodTypesForPayments {
#[schema(example = "klarna", value_type = PaymentMethodType)]
pub payment_method_subtype: common_enums::PaymentMethodType,
+ /// The payment experience for the payment method
+ #[schema(value_type = Option<PaymentExperience>)]
+ pub payment_experience: Option<common_enums::PaymentExperience>,
+
/// payment method subtype specific information
#[serde(flatten)]
#[schema(value_type = Option<PaymentMethodSubtypeSpecificData>)]
diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rs
index 887bd07891..208333ba0b 100644
--- a/crates/router/src/core/payments/payment_methods.rs
+++ b/crates/router/src/core/payments/payment_methods.rs
@@ -87,6 +87,9 @@ impl FilteredPaymentMethodsEnabled {
payment_method_subtype: payment_methods_enabled
.payment_methods_enabled
.payment_method_subtype,
+ payment_experience: payment_methods_enabled
+ .payment_methods_enabled
+ .payment_experience,
},
)
.collect();
@@ -100,6 +103,7 @@ struct RequiredFieldsForEnabledPaymentMethod {
required_field: Option<Vec<api_models::payment_methods::RequiredFieldInfo>>,
payment_method_subtype: common_enums::PaymentMethodType,
payment_method_type: common_enums::PaymentMethod,
+ payment_experience: Option<common_enums::PaymentExperience>,
}
/// Container to hold the filtered payment methods enabled with required fields
@@ -110,6 +114,7 @@ struct RequiredFieldsAndSurchargeForEnabledPaymentMethodType {
required_field: Option<Vec<api_models::payment_methods::RequiredFieldInfo>>,
payment_method_subtype: common_enums::PaymentMethodType,
payment_method_type: common_enums::PaymentMethod,
+ payment_experience: Option<common_enums::PaymentExperience>,
surcharge: Option<api_models::payment_methods::SurchargeDetailsResponse>,
}
@@ -127,6 +132,7 @@ impl RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes {
api_models::payments::ResponsePaymentMethodTypesForPayments {
payment_method_type: payment_methods_enabled.payment_method_type,
payment_method_subtype: payment_methods_enabled.payment_method_subtype,
+ payment_experience: payment_methods_enabled.payment_experience,
required_fields: payment_methods_enabled.required_field,
surcharge_details: payment_methods_enabled.surcharge,
extra_information: None,
@@ -153,6 +159,7 @@ impl RequiredFieldsForEnabledPaymentMethodTypes {
payment_method_type: payment_methods_enabled.payment_method_type,
required_field: payment_methods_enabled.required_field,
payment_method_subtype: payment_methods_enabled.payment_method_subtype,
+ payment_experience: payment_methods_enabled.payment_experience,
surcharge: None,
},
)