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(business_profile_v2): business profile v2 create and retrieve endpoint (#5606)

Narayan Bhat6e7b38a622d1
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml
index c94751b989..17e3105334 100644
--- a/.github/workflows/CI-pr.yml
+++ b/.github/workflows/CI-pr.yml
@@ -283,10 +283,6 @@ jobs:
name: Check compilation for V2 features
runs-on: ubuntu-latest
- env:
- # Allow the `clippy::todo` lint for v2 checks
- RUSTFLAGS: "-D warnings -A clippy::todo"
-
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -318,8 +314,17 @@ jobs:
tool: just
checksum: true
- - name: Cargo hack_v2
+ - name: Run cargo-hack on v2 features in select crates
shell: bash
env:
GH_TOKEN: ${{ github.token }}
+ RUSTFLAGS: "-D warnings -A clippy::todo"
run: just hack_v2
+
+ - name: Run cargo check with v2 features enabled
+ shell: bash
+ # env:
+ # # Not denying warnings for now.
+ # # We only want to ensure successful compilation for now.
+ # RUSTFLAGS: "-D warnings -A clippy::todo"
+ run: just check_v2
diff --git a/.typos.toml b/.typos.toml
index 2f68e039cd..0697f226c3 100644
--- a/.typos.toml
+++ b/.typos.toml
@@ -2,7 +2,8 @@
check-filename = true
[default.extend-identifiers]
-"ABD" = "ABD" # Aberdeenshire, UK ISO 3166-2 code
+ABD = "ABD" # Aberdeenshire, UK ISO 3166-2 code
+ACTIVITE = "ACTIVITE" # French translation of activity
AER = "AER" # An alias to Api Error Response
ANG = "ANG" # Netherlands Antillean guilder currency code
BA = "BA" # Bosnia and Herzegovina country code
@@ -62,20 +63,6 @@ extend-exclude = [
"openapi/open_api_spec.yaml", # no longer updated
"crates/router/src/utils/user/blocker_emails.txt", # this file contains various email domains
"CHANGELOG.md", # This file contains all the commits
- "crates/router/locales/ar.yml", # locales
- "crates/router/locales/ca.yml", # locales
- "crates/router/locales/de.yml", # locales
- "crates/router/locales/es.yml", # locales
- "crates/router/locales/fr-BE.yml", # locales
- "crates/router/locales/fr.yml", # locales
- "crates/router/locales/he.yml", # locales
- "crates/router/locales/it.yml", # locales
- "crates/router/locales/ja.yml", # locales
- "crates/router/locales/nl.yml", # locales
- "crates/router/locales/pl.yml", # locales
- "crates/router/locales/pt.yml", # locales
- "crates/router/locales/ru.yml", # locales
- "crates/router/locales/sv.yml", # locales
- "crates/router/locales/zh.yml", # locales
- "crates/router/src/core/payment_link/locale.js" # this file contains converision of static strings in various languages
+ "crates/router/locales/*.yml", # locales
+ "crates/router/src/core/payment_link/locale.js", # this file contains conversion of static strings in various languages
]
diff --git a/Cargo.lock b/Cargo.lock
index c0ff88bfcf..cf7718d887 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -451,6 +451,7 @@ dependencies = [
"indexmap 2.3.0",
"masking",
"mime",
+ "nutype",
"reqwest",
"router_derive",
"serde",
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index a52ebcdf9b..458e1ae9ff 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -2684,7 +2684,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
@@ -2738,7 +2738,7 @@
"items": {
"type": "string"
},
- "description": "Verified applepay domains for a particular profile",
+ "description": "Verified Apple Pay domains for a particular profile",
"nullable": true
},
"session_expiry": {
@@ -2847,7 +2847,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
@@ -2899,7 +2899,7 @@
"items": {
"type": "string"
},
- "description": "Verified applepay domains for a particular profile",
+ "description": "Verified Apple Pay domains for a particular profile",
"nullable": true
},
"session_expiry": {
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 0caaef1e53..8b082caa37 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -7162,7 +7162,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
@@ -7216,7 +7216,7 @@
"items": {
"type": "string"
},
- "description": "Verified applepay domains for a particular profile",
+ "description": "Verified Apple Pay domains for a particular profile",
"nullable": true
},
"session_expiry": {
@@ -7325,7 +7325,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
@@ -7377,7 +7377,7 @@
"items": {
"type": "string"
},
- "description": "Verified applepay domains for a particular profile",
+ "description": "Verified Apple Pay domains for a particular profile",
"nullable": true
},
"session_expiry": {
@@ -11511,7 +11511,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
@@ -11691,7 +11691,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.",
"example": "xkkdf909012sdjki2dkh5sdf",
"nullable": true,
"maxLength": 255
@@ -11874,7 +11874,7 @@
},
"payment_response_hash_key": {
"type": "string",
- "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.",
+ "description": "Refers to the hash key used for calculating the signature for webhooks and redirect response.",
"nullable": true
},
"redirect_to_merchant_with_http_post": {
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index 9935e41faa..e342fb3db9 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -39,6 +39,7 @@ strum = { version = "0.26", features = ["derive"] }
time = { version = "0.3.35", features = ["serde", "serde-well-known", "std"] }
url = { version = "2.5.0", features = ["serde"] }
utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] }
+nutype = { version = "0.4.2", features = ["serde"] }
# First party crates
cards = { version = "0.1.0", path = "../cards" }
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index f494b29712..b073c21951 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -26,7 +26,10 @@ use super::payments::AddressDetails;
not(feature = "merchant_account_v2")
))]
use crate::routing;
-use crate::{enums as api_enums, payment_methods};
+use crate::{
+ consts::{MAX_ORDER_FULFILLMENT_EXPIRY, MIN_ORDER_FULFILLMENT_EXPIRY},
+ enums as api_enums, payment_methods,
+};
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
pub struct MerchantAccountListRequest {
@@ -80,7 +83,7 @@ pub struct MerchantAccountCreate {
#[schema(default = false, example = true)]
pub enable_payment_response_hash: Option<bool>,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.
pub payment_response_hash_key: Option<String>,
/// A boolean value to indicate if redirect to merchant with http post needs to be enabled.
@@ -300,7 +303,7 @@ pub struct MerchantAccountUpdate {
#[schema(default = false, example = true)]
pub enable_payment_response_hash: Option<bool>,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response.
pub payment_response_hash_key: Option<String>,
/// A boolean value to indicate if redirect to merchant with http post needs to be enabled
@@ -462,7 +465,7 @@ pub struct MerchantAccountResponse {
#[schema(default = false, example = true)]
pub enable_payment_response_hash: bool,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.
#[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf")]
pub payment_response_hash_key: Option<String>,
@@ -1851,6 +1854,10 @@ pub struct MerchantConnectorDetails {
pub metadata: Option<pii::SecretSerdeValue>,
}
+#[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+))]
#[derive(Clone, Debug, Deserialize, ToSchema, Default, Serialize)]
#[serde(deny_unknown_fields)]
pub struct BusinessProfileCreate {
@@ -1866,7 +1873,7 @@ pub struct BusinessProfileCreate {
#[schema(default = true, example = true)]
pub enable_payment_response_hash: Option<bool>,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.
pub payment_response_hash_key: Option<String>,
/// A boolean value to indicate if redirect to merchant with http post needs to be enabled
@@ -1897,7 +1904,90 @@ pub struct BusinessProfileCreate {
#[schema(value_type = Option<RoutingAlgorithm>,example = json!({"type": "single", "data": "wise"}))]
pub payout_routing_algorithm: Option<serde_json::Value>,
- /// Verified applepay domains for a particular profile
+ /// Verified Apple Pay domains for a particular profile
+ pub applepay_verified_domains: Option<Vec<String>>,
+
+ /// Client Secret Default expiry for all payments created under this business profile
+ #[schema(example = 900)]
+ pub session_expiry: Option<u32>,
+
+ /// Default Payment Link config for all payment links created under this business profile
+ pub payment_link_config: Option<BusinessPaymentLinkConfig>,
+
+ /// External 3DS authentication details
+ pub authentication_connector_details: Option<AuthenticationConnectorDetails>,
+
+ /// Whether to use the billing details passed when creating the intent as payment method billing
+ pub use_billing_as_payment_method_billing: Option<bool>,
+
+ /// A boolean value to indicate if customer shipping details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ #[schema(default = false, example = false)]
+ pub collect_shipping_details_from_wallet_connector: Option<bool>,
+
+ /// A boolean value to indicate if customer billing details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ #[schema(default = false, example = false)]
+ pub collect_billing_details_from_wallet_connector: Option<bool>,
+
+ /// Indicates if the MIT (merchant initiated transaction) payments can be made connector
+ /// agnostic, i.e., MITs may be processed through different connector than CIT (customer
+ /// initiated transaction) based on the routing rules.
+ /// If set to `false`, MIT will go through the same connector as the CIT.
+ pub is_connector_agnostic_mit_enabled: Option<bool>,
+
+ /// Default payout link config
+ #[schema(value_type = Option<BusinessPayoutLinkConfig>)]
+ pub payout_link_config: Option<BusinessPayoutLinkConfig>,
+
+ /// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.
+ #[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
+ pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
+}
+
+#[nutype::nutype(
+ validate(greater_or_equal = MIN_ORDER_FULFILLMENT_EXPIRY, less_or_equal = MAX_ORDER_FULFILLMENT_EXPIRY),
+ derive(Clone, Debug, Deserialize,Serialize)
+)]
+pub struct OrderFulfillmentTime(i64);
+
+#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+#[derive(Clone, Debug, Deserialize, ToSchema, Default, Serialize)]
+#[serde(deny_unknown_fields)]
+pub struct BusinessProfileCreate {
+ /// The name of business profile
+ #[schema(max_length = 64)]
+ pub profile_name: String,
+
+ /// The URL to redirect after the completion of the operation
+ #[schema(value_type = Option<String>, max_length = 255, example = "https://www.example.com/success")]
+ pub return_url: Option<url::Url>,
+
+ /// A boolean value to indicate if payment response hash needs to be enabled
+ #[schema(default = true, example = true)]
+ pub enable_payment_response_hash: Option<bool>,
+
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a value is automatically generated.
+ pub payment_response_hash_key: Option<String>,
+
+ /// A boolean value to indicate if redirect to merchant with http post needs to be enabled
+ #[schema(default = false, example = true)]
+ pub redirect_to_merchant_with_http_post: Option<bool>,
+
+ /// Webhook related details
+ pub webhook_details: Option<WebhookDetails>,
+
+ /// Metadata is useful for storing additional, unstructured information on an object.
+ #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
+ pub metadata: Option<pii::SecretSerdeValue>,
+
+ /// Will be used to determine the time till which your payment will be active once the payment session starts
+ #[schema(value_type = u32, example = 900)]
+ pub order_fulfillment_time: Option<OrderFulfillmentTime>,
+
+ /// Whether the order fulfillment time is calculated from the origin or the time of creating the payment, or confirming the payment
+ #[schema(value_type = Option<OrderFulfillmentTimeOrigin>, example = "create")]
+ pub order_fulfillment_time_origin: Option<api_enums::OrderFulfillmentTimeOrigin>,
+
+ /// Verified Apple Pay domains for a particular profile
pub applepay_verified_domains: Option<Vec<String>>,
/// Client Secret Default expiry for all payments created under this business profile
@@ -1936,6 +2026,10 @@ pub struct BusinessProfileCreate {
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
}
+#[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+))]
#[derive(Clone, Debug, ToSchema, Serialize)]
pub struct BusinessProfileResponse {
/// The identifier for Merchant Account
@@ -1958,7 +2052,7 @@ pub struct BusinessProfileResponse {
#[schema(default = true, example = true)]
pub enable_payment_response_hash: bool,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response.
pub payment_response_hash_key: Option<String>,
/// A boolean value to indicate if redirect to merchant with http post needs to be enabled
@@ -1989,7 +2083,7 @@ pub struct BusinessProfileResponse {
#[schema(value_type = Option<RoutingAlgorithm>,example = json!({"type": "single", "data": "wise"}))]
pub payout_routing_algorithm: Option<serde_json::Value>,
- /// Verified applepay domains for a particular profile
+ /// Verified Apple Pay domains for a particular profile
pub applepay_verified_domains: Option<Vec<String>>,
/// Client Secret Default expiry for all payments created under this business profile
@@ -2032,6 +2126,94 @@ pub struct BusinessProfileResponse {
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, Secret<String>>>,
}
+#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+#[derive(Clone, Debug, ToSchema, Serialize)]
+pub struct BusinessProfileResponse {
+ /// The identifier for Merchant Account
+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]
+ pub merchant_id: id_type::MerchantId,
+
+ /// The identifier for business profile. This must be used for creating merchant accounts, payments and payouts
+ #[schema(max_length = 64, example = "pro_abcdefghijklmnopqrstuvwxyz")]
+ pub id: String,
+
+ /// Name of the business profile
+ #[schema(max_length = 64)]
+ pub profile_name: String,
+
+ /// The URL to redirect after the completion of the operation
+ #[schema(value_type = Option<String>, max_length = 255, example = "https://www.example.com/success")]
+ pub return_url: Option<String>,
+
+ /// A boolean value to indicate if payment response hash needs to be enabled
+ #[schema(default = true, example = true)]
+ pub enable_payment_response_hash: bool,
+
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response.
+ pub payment_response_hash_key: Option<String>,
+
+ /// A boolean value to indicate if redirect to merchant with http post needs to be enabled
+ #[schema(default = false, example = true)]
+ pub redirect_to_merchant_with_http_post: bool,
+
+ /// Webhook related details
+ pub webhook_details: Option<WebhookDetails>,
+
+ /// Metadata is useful for storing additional, unstructured information on an object.
+ #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
+ pub metadata: Option<pii::SecretSerdeValue>,
+
+ /// Verified Apple Pay domains for a particular profile
+ pub applepay_verified_domains: Option<Vec<String>>,
+
+ /// Client Secret Default expiry for all payments created under this business profile
+ #[schema(example = 900)]
+ pub session_expiry: Option<i64>,
+
+ /// Default Payment Link config for all payment links created under this business profile
+ #[schema(value_type = Option<BusinessPaymentLinkConfig>)]
+ pub payment_link_config: Option<BusinessPaymentLinkConfig>,
+
+ /// External 3DS authentication details
+ pub authentication_connector_details: Option<AuthenticationConnectorDetails>,
+
+ // Whether to use the billing details passed when creating the intent as payment method billing
+ pub use_billing_as_payment_method_billing: Option<bool>,
+
+ /// Merchant's config to support extended card info feature
+ pub extended_card_info_config: Option<ExtendedCardInfoConfig>,
+
+ /// A boolean value to indicate if customer shipping details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ #[schema(default = false, example = false)]
+ pub collect_shipping_details_from_wallet_connector: Option<bool>,
+
+ /// A boolean value to indicate if customer billing details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ #[schema(default = false, example = false)]
+ pub collect_billing_details_from_wallet_connector: Option<bool>,
+
+ /// Indicates if the MIT (merchant initiated transaction) payments can be made connector
+ /// agnostic, i.e., MITs may be processed through different connector than CIT (customer
+ /// initiated transaction) based on the routing rules.
+ /// If set to `false`, MIT will go through the same connector as the CIT.
+ pub is_connector_agnostic_mit_enabled: Option<bool>,
+
+ /// Default payout link config
+ #[schema(value_type = Option<BusinessPayoutLinkConfig>)]
+ pub payout_link_config: Option<BusinessPayoutLinkConfig>,
+
+ /// These key-value pairs are sent as additional custom headers in the outgoing webhook request.
+ #[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
+ pub outgoing_webhook_custom_http_headers: Option<HashMap<String, Secret<String>>>,
+
+ /// Will be used to determine the time till which your payment will be active once the payment session starts
+ #[schema(value_type = u32, example = 900)]
+ pub order_fulfillment_time: Option<OrderFulfillmentTime>,
+
+ /// Whether the order fulfillment time is calculated from the origin or the time of creating the payment, or confirming the payment
+ #[schema(value_type = Option<OrderFulfillmentTimeOrigin>, example = "create")]
+ pub order_fulfillment_time_origin: Option<api_enums::OrderFulfillmentTimeOrigin>,
+}
+
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
#[serde(deny_unknown_fields)]
pub struct BusinessProfileUpdate {
@@ -2047,7 +2229,7 @@ pub struct BusinessProfileUpdate {
#[schema(default = true, example = true)]
pub enable_payment_response_hash: Option<bool>,
- /// Refers to the hash key used for calculating the signature for webhooks and redirect response. If the value is not provided, a default value is used.
+ /// Refers to the hash key used for calculating the signature for webhooks and redirect response.
pub payment_response_hash_key: Option<String>,
/// A boolean value to indicate if redirect to merchant with http post needs to be enabled
@@ -2078,7 +2260,7 @@ pub struct BusinessProfileUpdate {
#[schema(value_type = Option<RoutingAlgorithm>,example = json!({"type": "single", "data": "wise"}))]
pub payout_routing_algorithm: Option<serde_json::Value>,
- /// Verified applepay domains for a particular profile
+ /// Verified Apple Pay domains for a particular profile
pub applepay_verified_domains: Option<Vec<String>>,
/// Client Secret Default expiry for all payments created under this business profile
@@ -2097,11 +2279,11 @@ pub struct BusinessProfileUpdate {
// Whether to use the billing details passed when creating the intent as payment method billing
pub use_billing_as_payment_method_billing: Option<bool>,
- /// A boolean value to indicate if customer shipping details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ /// A boolean value to indicate if customer shipping details needs to be collected from wallet connector (Eg. Apple Pay, Google Pay, etc.)
#[schema(default = false, example = false)]
pub collect_shipping_details_from_wallet_connector: Option<bool>,
- /// A boolean value to indicate if customer billing details needs to be collected from wallet connector (Eg. Apple pay, Google pay etc)
+ /// A boolean value to indicate if customer billing details needs to be collected from wallet connector (Eg. Apple Pay, Google Pay, etc.)
#[schema(default = false, example = false)]
pub collect_billing_details_from_wallet_connector: Option<bool>,
diff --git a/crates/api_models/src/consts.rs b/crates/api_models/src/consts.rs
new file mode 100644
index 0000000000..1a9c79080c
--- /dev/null
+++ b/crates/api_models/src/consts.rs
@@ -0,0 +1,5 @@
+/// Max payment intent fulfillment expiry
+pub const MAX_ORDER_FULFILLMENT_EXPIRY: i64 = 1800;
+
+/// Min payment intent fulfillment expiry
+pub const MIN_ORDER_FULFILLMENT_EXPIRY: i64 = 60;
diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs
index 938a6f2379..daa329a763 100644
--- a/crates/api_models/src/lib.rs
+++ b/crates/api_models/src/lib.rs
@@ -6,6 +6,7 @@ pub mod blocklist;
pub mod cards_info;
pub mod conditional_configs;
pub mod connector_onboarding;
+pub mod consts;
pub mod currency;
pub mod customers;
pub mod disputes;
diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rs
index fd15596396..28c0cf7441 100644
--- a/crates/common_utils/src/consts.rs
+++ b/crates/common_utils/src/consts.rs
@@ -77,6 +77,9 @@ pub const DEFAULT_SESSION_EXPIRY: i64 = 15 * 60;
/// Payment intent fulfillment time (in seconds)
pub const DEFAULT_INTENT_FULFILLMENT_TIME: i64 = 15 * 60;
+/// Payment order fulfillment time (in seconds)
+pub const DEFAULT_ORDER_FULFILLMENT_TIME: i64 = 15 * 60;
+
/// Default bool for Display sdk only
pub const DEFAULT_DISPLAY_SDK_ONLY: bool = false;
diff --git a/crates/common_utils/src/errors.rs b/crates/common_utils/src/errors.rs
index 23b4f2be4f..38b89cbfaf 100644
--- a/crates/common_utils/src/errors.rs
+++ b/crates/common_utils/src/errors.rs
@@ -50,6 +50,9 @@ pub enum ParsingError {
/// Failed to parse String value to Decimal value conversion because `error`
#[error("Failed to parse String value to Decimal value conversion because {error}")]
StringToDecimalConversionFailure { error: String },
+ /// Failed to convert the given integer because of integer overflow error
+ #[error("Integer Overflow error")]
+ IntegerOverflow,
}
/// Validation errors.
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index cf873d4b61..0877859737 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -1,8 +1,6 @@
use std::collections::{HashMap, HashSet};
use common_enums::AuthenticationConnectors;
-// #[cfg(all(feature = "v2", feature = "business_profile_v2"))]
-// use common_enums::OrderFulfillmentTimeOrigin;
use common_utils::{encryption::Encryption, pii};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use masking::Secret;
@@ -231,7 +229,6 @@ pub struct BusinessProfile {
pub redirect_to_merchant_with_http_post: bool,
pub webhook_details: Option<WebhookDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
- pub intent_fulfillment_time: Option<i64>,
pub is_recon_enabled: bool,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
@@ -247,8 +244,8 @@ pub struct BusinessProfile {
pub collect_billing_details_from_wallet_connector: Option<bool>,
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub routing_algorithm_id: Option<String>,
- // pub order_fulfillment_time: Option<i64>,
- // pub order_fulfillment_time_origin: Option<OrderFulfillmentTimeOrigin>,
+ pub order_fulfillment_time: Option<i64>,
+ pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
@@ -269,7 +266,6 @@ pub struct BusinessProfileNew {
pub redirect_to_merchant_with_http_post: bool,
pub webhook_details: Option<WebhookDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
- pub intent_fulfillment_time: Option<i64>,
pub is_recon_enabled: bool,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
@@ -285,8 +281,8 @@ pub struct BusinessProfileNew {
pub collect_billing_details_from_wallet_connector: Option<bool>,
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub routing_algorithm_id: Option<String>,
- // pub order_fulfillment_time: Option<i64>,
- // pub order_fulfillment_time_origin: Option<OrderFulfillmentTimeOrigin>,
+ pub order_fulfillment_time: Option<i64>,
+ pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
@@ -304,7 +300,6 @@ pub struct BusinessProfileUpdateInternal {
pub redirect_to_merchant_with_http_post: Option<bool>,
pub webhook_details: Option<WebhookDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
- pub intent_fulfillment_time: Option<i64>,
pub is_recon_enabled: Option<bool>,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
@@ -320,8 +315,8 @@ pub struct BusinessProfileUpdateInternal {
pub collect_billing_details_from_wallet_connector: Option<bool>,
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub routing_algorithm_id: Option<String>,
- // pub order_fulfillment_time: Option<i64>,
- // pub order_fulfillment_time_origin: Option<OrderFulfillmentTimeOrigin>,
+ pub order_fulfillment_time: Option<i64>,
+ pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
@@ -353,9 +348,8 @@ impl BusinessProfileUpdateInternal {
collect_billing_details_from_wallet_connector,
outgoing_webhook_custom_http_headers,
routing_algorithm_id,
- intent_fulfillment_time,
- // order_fulfillment_time,
- // order_fulfillment_time_origin,
+ order_fulfillment_time,
+ order_fulfillment_time_origin,
frm_routing_algorithm_id,
payout_routing_algorithm_id,
default_fallback_routing,
@@ -400,10 +394,9 @@ impl BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers
.or(source.outgoing_webhook_custom_http_headers),
routing_algorithm_id: routing_algorithm_id.or(source.routing_algorithm_id),
- intent_fulfillment_time: intent_fulfillment_time.or(source.intent_fulfillment_time),
- // order_fulfillment_time: order_fulfillment_time.or(source.order_fulfillment_time),
- // order_fulfillment_time_origin: order_fulfillment_time_origin
- // .or(source.order_fulfillment_time_origin),
+ order_fulfillment_time: order_fulfillment_time.or(source.order_fulfillment_time),
+ order_fulfillment_time_origin: order_fulfillment_time_origin
+ .or(source.order_fulfillment_time_origin),
frm_routing_algorithm_id: frm_routing_algorithm_id.or(source.frm_routing_algorithm_id),
payout_routing_algorithm_id: payout_routing_algorithm_id
.or(source.payout_routing_algorithm_id),
@@ -446,9 +439,8 @@ impl From<BusinessProfileNew> for BusinessProfile {
.collect_billing_details_from_wallet_connector,
outgoing_webhook_custom_http_headers: new.outgoing_webhook_custom_http_headers,
routing_algorithm_id: new.routing_algorithm_id,
- intent_fulfillment_time: new.intent_fulfillment_time,
- // order_fulfillment_time: new.order_fulfillment_time,
- // order_fulfillment_time_origin: new.order_fulfillment_time_origin,
+ order_fulfillment_time: new.order_fulfillment_time,
+ order_fulfillment_time_origin: new.order_fulfillment_time_origin,
frm_routing_algorithm_id: new.frm_routing_algorithm_id,
payout_routing_algorithm_id: new.payout_routing_algorithm_id,
default_fallback_routing: new.default_fallback_routing,
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 59822bbdfb..12f515b9ca 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -188,7 +188,6 @@ diesel::table! {
redirect_to_merchant_with_http_post -> Bool,
webhook_details -> Nullable<Json>,
metadata -> Nullable<Json>,
- intent_fulfillment_time -> Nullable<Int8>,
is_recon_enabled -> Bool,
applepay_verified_domains -> Nullable<Array<Nullable<Text>>>,
payment_link_config -> Nullable<Jsonb>,
@@ -204,6 +203,8 @@ diesel::table! {
outgoing_webhook_custom_http_headers -> Nullable<Bytea>,
#[max_length = 64]
routing_algorithm_id -> Nullable<Varchar>,
+ order_fulfillment_time -> Nullable<Int8>,
+ order_fulfillment_time_origin -> Nullable<OrderFulfillmentTimeOrigin>,
#[max_length = 64]
frm_routing_algorithm_id -> Nullable<Varchar>,
#[max_length = 64]
diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rs
index fa9af562cf..2af48930ed 100644
--- a/crates/hyperswitch_domain_models/src/business_profile.rs
+++ b/crates/hyperswitch_domain_models/src/business_profile.rs
@@ -420,7 +420,6 @@ pub struct BusinessProfile {
pub redirect_to_merchant_with_http_post: bool,
pub webhook_details: Option<WebhookDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
- pub intent_fulfillment_time: Option<i64>,
pub is_recon_enabled: bool,
pub applepay_verified_domains: Option<Vec<String>>,
pub payment_link_config: Option<BusinessPaymentLinkConfig>,
@@ -435,13 +434,28 @@ pub struct BusinessProfile {
pub collect_billing_details_from_wallet_connector: Option<bool>,
pub outgoing_webhook_custom_http_headers: OptionalEncryptableValue,
pub routing_algorithm_id: Option<String>,
- // pub order_fulfillment_time: Option<i64>,
- // pub order_fulfillment_time_origin: Option<OrderFulfillmentTimeOrigin>,
+ pub order_fulfillment_time: Option<i64>,
+ pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
}
+impl BusinessProfile {
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+ ))]
+ pub fn get_order_fulfillment_time(&self) -> Option<i64> {
+ self.intent_fulfillment_time
+ }
+
+ #[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+ pub fn get_order_fulfillment_time(&self) -> Option<i64> {
+ self.order_fulfillment_time
+ }
+}
+
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
#[derive(Debug)]
pub struct BusinessProfileGeneralUpdate {
@@ -452,7 +466,6 @@ pub struct BusinessProfileGeneralUpdate {
pub redirect_to_merchant_with_http_post: Option<bool>,
pub webhook_details: Option<WebhookDetails>,
pub metadata: Option<pii::SecretSerdeValue>,
- pub intent_fulfillment_time: Option<i64>,
pub is_recon_enabled: Option<bool>,
pub applepay_verified_domains: Option<Vec<String>>,
pub payment_link_config: Option<BusinessPaymentLinkConfig>,
@@ -466,8 +479,8 @@ pub struct BusinessProfileGeneralUpdate {
pub is_connector_agnostic_mit_enabled: Option<bool>,
pub outgoing_webhook_custom_http_headers: OptionalEncryptableValue,
pub routing_algorithm_id: Option<String>,
- // pub order_fulfillment_time: Option<i64>,
- // pub order_fulfillment_time_origin: Option<OrderFulfillmentTimeOrigin>,
+ pub order_fulfillment_time: Option<i64>,
+ pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
@@ -507,7 +520,6 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
redirect_to_merchant_with_http_post,
webhook_details,
metadata,
- intent_fulfillment_time,
is_recon_enabled,
applepay_verified_domains,
payment_link_config,
@@ -521,8 +533,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
is_connector_agnostic_mit_enabled,
outgoing_webhook_custom_http_headers,
routing_algorithm_id,
- // order_fulfillment_time,
- // order_fulfillment_time_origin,
+ order_fulfillment_time,
+ order_fulfillment_time_origin,
frm_routing_algorithm_id,
payout_routing_algorithm_id,
default_fallback_routing,
@@ -536,7 +548,6 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
redirect_to_merchant_with_http_post,
webhook_details,
metadata,
- intent_fulfillment_time,
is_recon_enabled,
applepay_verified_domains,
payment_link_config,
@@ -552,8 +563,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers
.map(Encryption::from),
routing_algorithm_id,
- // order_fulfillment_time,
- // order_fulfillment_time_origin,
+ order_fulfillment_time,
+ order_fulfillment_time_origin,
frm_routing_algorithm_id,
payout_routing_algorithm_id,
default_fallback_routing,
@@ -585,9 +596,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
collect_billing_details_from_wallet_connector: None,
outgoing_webhook_custom_http_headers: None,
routing_algorithm_id,
- intent_fulfillment_time: None,
- // order_fulfillment_time: None,
- // order_fulfillment_time_origin: None,
+ order_fulfillment_time: None,
+ order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
payout_routing_algorithm_id,
default_fallback_routing: None,
@@ -618,9 +628,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
routing_algorithm_id: None,
payout_routing_algorithm_id: None,
- intent_fulfillment_time: None,
- // order_fulfillment_time: None,
- // order_fulfillment_time_origin: None,
+ order_fulfillment_time: None,
+ order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing: None,
},
@@ -650,9 +659,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
routing_algorithm_id: None,
payout_routing_algorithm_id: None,
- intent_fulfillment_time: None,
- // order_fulfillment_time: None,
- // order_fulfillment_time_origin: None,
+ order_fulfillment_time: None,
+ order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing: None,
},
@@ -682,9 +690,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
routing_algorithm_id: None,
payout_routing_algorithm_id: None,
- intent_fulfillment_time: None,
- // order_fulfillment_time: None,
- // order_fulfillment_time_origin: None,
+ order_fulfillment_time: None,
+ order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing,
},
@@ -730,9 +737,8 @@ impl super::behaviour::Conversion for BusinessProfile {
.map(Encryption::from),
routing_algorithm_id: self.routing_algorithm_id,
payout_routing_algorithm_id: self.payout_routing_algorithm_id,
- intent_fulfillment_time: self.intent_fulfillment_time,
- // order_fulfillment_time: self.order_fulfillment_time,
- // order_fulfillment_time_origin: self.order_fulfillment_time_origin,
+ order_fulfillment_time: self.order_fulfillment_time,
+ order_fulfillment_time_origin: self.order_fulfillment_time_origin,
frm_routing_algorithm_id: self.frm_routing_algorithm_id,
default_fallback_routing: self.default_fallback_routing,
})
@@ -789,10 +795,8 @@ impl super::behaviour::Conversion for BusinessProfile {
})
.await?,
routing_algorithm_id: item.routing_algorithm_id,
-
- intent_fulfillment_time: item.intent_fulfillment_time,
- // order_fulfillment_time: item.order_fulfillment_time,
- // order_fulfillment_time_origin: item.order_fulfillment_time_origin,
+ order_fulfillment_time: item.order_fulfillment_time,
+ order_fulfillment_time_origin: item.order_fulfillment_time_origin,
frm_routing_algorithm_id: item.frm_routing_algorithm_id,
payout_routing_algorithm_id: item.payout_routing_algorithm_id,
default_fallback_routing: item.default_fallback_routing,
@@ -835,9 +839,8 @@ impl super::behaviour::Conversion for BusinessProfile {
.outgoing_webhook_custom_http_headers
.map(Encryption::from),
routing_algorithm_id: self.routing_algorithm_id,
- intent_fulfillment_time: self.intent_fulfillment_time,
- // order_fulfillment_time: self.order_fulfillment_time,
- // order_fulfillment_time_origin: self.order_fulfillment_time_origin,
+ order_fulfillment_time: self.order_fulfillment_time,
+ order_fulfillment_time_origin: self.order_fulfillment_time_origin,
frm_routing_algorithm_id: self.frm_routing_algorithm_id,
payout_routing_algorithm_id: self.payout_routing_algorithm_id,
default_fallback_routing: self.default_fallback_routing,
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 00bfe2f7c1..1f5fb06840 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -3270,25 +3270,23 @@ pub fn get_frm_config_as_secret(
}
}
-#[cfg(any(feature = "v1", feature = "v2"))]
+#[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+))]
pub async fn create_and_insert_business_profile(
state: &SessionState,
request: api::BusinessProfileCreate,
merchant_account: domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<domain::BusinessProfile> {
- #[cfg(all(
- any(feature = "v1", feature = "v2"),
- not(feature = "merchant_account_v2")
- ))]
- let business_profile_new =
- admin::create_business_profile(state, merchant_account, request, key_store).await?;
-
- #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]
- let business_profile_new = {
- let _ = merchant_account;
- admin::create_business_profile(state, request, key_store).await?
- };
+ let business_profile_new = admin::create_business_profile_from_merchant_account(
+ state,
+ merchant_account,
+ request,
+ key_store,
+ )
+ .await?;
let profile_name = business_profile_new.profile_name.clone();
@@ -3304,23 +3302,261 @@ pub async fn create_and_insert_business_profile(
.attach_printable("Failed to insert Business profile because of duplication error")
}
-#[cfg(all(
- any(feature = "v1", feature = "v2"),
- not(any(feature = "merchant_account_v2", feature = "business_profile_v2"))
-))]
+#[cfg(feature = "olap")]
+#[async_trait::async_trait]
+trait BusinessProfileCreateBridge {
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+ ))]
+ async fn create_domain_model_from_request(
+ self,
+ state: &SessionState,
+ merchant_account: &domain::MerchantAccount,
+ key: &domain::MerchantKeyStore,
+ ) -> RouterResult<domain::BusinessProfile>;
+
+ #[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+ async fn create_domain_model_from_request(
+ self,
+ state: &SessionState,
+ key: &domain::MerchantKeyStore,
+ merchant_id: &id_type::MerchantId,
+ ) -> RouterResult<domain::BusinessProfile>;
+}
+
+#[cfg(feature = "olap")]
+#[async_trait::async_trait]
+impl BusinessProfileCreateBridge for api::BusinessProfileCreate {
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+ ))]
+ async fn create_domain_model_from_request(
+ self,
+ state: &SessionState,
+ merchant_account: &domain::MerchantAccount,
+ key_store: &domain::MerchantKeyStore,
+ ) -> RouterResult<domain::BusinessProfile> {
+ use common_utils::ext_traits::AsyncExt;
+
+ if let Some(session_expiry) = &self.session_expiry {
+ helpers::validate_session_expiry(session_expiry.to_owned())?;
+ }
+
+ if let Some(intent_fulfillment_expiry) = &self.intent_fulfillment_time {
+ helpers::validate_intent_fulfillment_expiry(intent_fulfillment_expiry.to_owned())?;
+ }
+
+ if let Some(ref routing_algorithm) = self.routing_algorithm {
+ let _: api_models::routing::RoutingAlgorithm = routing_algorithm
+ .clone()
+ .parse_value("RoutingAlgorithm")
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "routing_algorithm",
+ })
+ .attach_printable("Invalid routing algorithm given")?;
+ }
+
+ // Generate a unique profile id
+ let profile_id = common_utils::generate_id_with_default_len("pro");
+ let profile_name = self.profile_name.unwrap_or("default".to_string());
+
+ let current_time = date_time::now();
+
+ let webhook_details = self.webhook_details.map(ForeignInto::foreign_into);
+
+ let payment_response_hash_key = self
+ .payment_response_hash_key
+ .or(merchant_account.payment_response_hash_key.clone())
+ .unwrap_or(common_utils::crypto::generate_cryptographically_secure_random_string(64));
+
+ let payment_link_config = self.payment_link_config.map(ForeignInto::foreign_into);
+ let outgoing_webhook_custom_http_headers = self
+ .outgoing_webhook_custom_http_headers
+ .async_map(|headers| cards::create_encrypted_data(state, key_store, headers))
+ .await
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encrypt outgoing webhook custom HTTP headers")?;
+
+ let payout_link_config = self
+ .payout_link_config
+ .map(|payout_conf| match payout_conf.config.validate() {
+ Ok(_) => Ok(payout_conf.foreign_into()),
+ Err(e) => Err(error_stack::report!(
+ errors::ApiErrorResponse::InvalidRequestData {
+ message: e.to_string()
+ }
+ )),
+ })
+ .transpose()?;
+
+ Ok(domain::BusinessProfile {
+ profile_id,
+ merchant_id: merchant_account.get_id().clone(),
+ profile_name,
+ created_at: current_time,
+ modified_at: current_time,
+ return_url: self
+ .return_url
+ .map(|return_url| return_url.to_string())
+ .or(merchant_account.return_url.clone()),
+ enable_payment_response_hash: self
+ .enable_payment_response_hash
+ .unwrap_or(merchant_account.enable_payment_response_hash),
+ payment_response_hash_key: Some(payment_response_hash_key),
+ redirect_to_merchant_with_http_post: self
+ .redirect_to_merchant_with_http_post
+ .unwrap_or(merchant_account.redirect_to_merchant_with_http_post),
+ webhook_details: webhook_details.or(merchant_account.webhook_details.clone()),
+ metadata: self.metadata,
+ routing_algorithm: None,
+ intent_fulfillment_time: self
+ .intent_fulfillment_time
+ .map(i64::from)
+ .or(merchant_account.intent_fulfillment_time)
+ .or(Some(common_utils::consts::DEFAULT_INTENT_FULFILLMENT_TIME)),
+ frm_routing_algorithm: self
+ .frm_routing_algorithm
+ .or(merchant_account.frm_routing_algorithm.clone()),
+ #[cfg(feature = "payouts")]
+ payout_routing_algorithm: self
+ .payout_routing_algorithm
+ .or(merchant_account.payout_routing_algorithm.clone()),
+ #[cfg(not(feature = "payouts"))]
+ payout_routing_algorithm: None,
+ is_recon_enabled: merchant_account.is_recon_enabled,
+ applepay_verified_domains: self.applepay_verified_domains,
+ payment_link_config,
+ session_expiry: self
+ .session_expiry
+ .map(i64::from)
+ .or(Some(common_utils::consts::DEFAULT_SESSION_EXPIRY)),
+ authentication_connector_details: self
+ .authentication_connector_details
+ .map(ForeignInto::foreign_into),
+ payout_link_config,
+ is_connector_agnostic_mit_enabled: self.is_connector_agnostic_mit_enabled,
+ is_extended_card_info_enabled: None,
+ extended_card_info_config: None,
+ use_billing_as_payment_method_billing: self
+ .use_billing_as_payment_method_billing
+ .or(Some(true)),
+ collect_shipping_details_from_wallet_connector: self
+ .collect_shipping_details_from_wallet_connector
+ .or(Some(false)),
+ collect_billing_details_from_wallet_connector: self
+ .collect_billing_details_from_wallet_connector
+ .or(Some(false)),
+ outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers
+ .map(Into::into),
+ })
+ }
+
+ #[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+ async fn create_domain_model_from_request(
+ self,
+ state: &SessionState,
+ key_store: &domain::MerchantKeyStore,
+ merchant_id: &id_type::MerchantId,
+ ) -> RouterResult<domain::BusinessProfile> {
+ if let Some(session_expiry) = &self.session_expiry {
+ helpers::validate_session_expiry(session_expiry.to_owned())?;
+ }
+
+ // Generate a unique profile id
+ // TODO: the profile_id should be generated from the profile_name
+ let profile_id = common_utils::generate_id_with_default_len("pro");
+ let profile_name = self.profile_name;
+
+ let current_time = date_time::now();
+
+ let webhook_details = self.webhook_details.map(ForeignInto::foreign_into);
+
+ let payment_response_hash_key = self
+ .payment_response_hash_key
+ .unwrap_or(common_utils::crypto::generate_cryptographically_secure_random_string(64));
+
+ let payment_link_config = self.payment_link_config.map(ForeignInto::foreign_into);
+ let outgoing_webhook_custom_http_headers = self
+ .outgoing_webhook_custom_http_headers
+ .async_map(|headers| cards::create_encrypted_data(state, key_store, headers))
+ .await
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encrypt outgoing webhook custom HTTP headers")?;
+
+ let payout_link_config = self
+ .payout_link_config
+ .map(|payout_conf| match payout_conf.config.validate() {
+ Ok(_) => Ok(payout_conf.foreign_into()),
+ Err(e) => Err(error_stack::report!(
+ errors::ApiErrorResponse::InvalidRequestData {
+ message: e.to_string()
+ }
+ )),
+ })
+ .transpose()?;
+
+ Ok(domain::BusinessProfile {
+ profile_id,
+ merchant_id: merchant_id.clone(),
+ profile_name,
+ created_at: current_time,
+ modified_at: current_time,
+ return_url: self.return_url.map(|return_url| return_url.to_string()),
+ enable_payment_response_hash: self.enable_payment_response_hash.unwrap_or(true),
+ payment_response_hash_key: Some(payment_response_hash_key),
+ redirect_to_merchant_with_http_post: self
+ .redirect_to_merchant_with_http_post
+ .unwrap_or(true),
+ webhook_details,
+ metadata: self.metadata,
+ is_recon_enabled: false,
+ applepay_verified_domains: self.applepay_verified_domains,
+ payment_link_config,
+ session_expiry: self
+ .session_expiry
+ .map(i64::from)
+ .or(Some(common_utils::consts::DEFAULT_SESSION_EXPIRY)),
+ authentication_connector_details: self
+ .authentication_connector_details
+ .map(ForeignInto::foreign_into),
+ payout_link_config,
+ is_connector_agnostic_mit_enabled: self.is_connector_agnostic_mit_enabled,
+ is_extended_card_info_enabled: None,
+ extended_card_info_config: None,
+ use_billing_as_payment_method_billing: self
+ .use_billing_as_payment_method_billing
+ .or(Some(true)),
+ collect_shipping_details_from_wallet_connector: self
+ .collect_shipping_details_from_wallet_connector
+ .or(Some(false)),
+ collect_billing_details_from_wallet_connector: self
+ .collect_billing_details_from_wallet_connector
+ .or(Some(false)),
+ outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers
+ .map(Into::into),
+ routing_algorithm_id: None,
+ frm_routing_algorithm_id: None,
+ payout_routing_algorithm_id: None,
+ order_fulfillment_time: self
+ .order_fulfillment_time
+ .map(|order_fulfillment_time| i64::from(order_fulfillment_time.into_inner()))
+ .or(Some(common_utils::consts::DEFAULT_ORDER_FULFILLMENT_TIME)),
+ order_fulfillment_time_origin: self.order_fulfillment_time_origin,
+ default_fallback_routing: None,
+ })
+ }
+}
+
+#[cfg(feature = "olap")]
pub async fn create_business_profile(
state: SessionState,
request: api::BusinessProfileCreate,
merchant_id: &id_type::MerchantId,
) -> RouterResponse<api_models::admin::BusinessProfileResponse> {
- if let Some(session_expiry) = &request.session_expiry {
- helpers::validate_session_expiry(session_expiry.to_owned())?;
- }
-
- if let Some(intent_fulfillment_expiry) = &request.intent_fulfillment_time {
- helpers::validate_intent_fulfillment_expiry(intent_fulfillment_expiry.to_owned())?;
- }
-
let db = state.store.as_ref();
let key_manager_state = &(&state).into();
let key_store = db
@@ -3339,20 +3575,33 @@ pub async fn create_business_profile(
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
- if let Some(ref routing_algorithm) = request.routing_algorithm {
- let _: api_models::routing::RoutingAlgorithm = routing_algorithm
- .clone()
- .parse_value("RoutingAlgorithm")
- .change_context(errors::ApiErrorResponse::InvalidDataValue {
- field_name: "routing_algorithm",
- })
- .attach_printable("Invalid routing algorithm given")?;
- }
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+ ))]
+ let business_profile = request
+ .create_domain_model_from_request(&state, &merchant_account, &key_store)
+ .await?;
- let business_profile =
- create_and_insert_business_profile(&state, request, merchant_account.clone(), &key_store)
- .await?;
+ #[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+ let business_profile = request
+ .create_domain_model_from_request(&state, &key_store, merchant_account.get_id())
+ .await?;
+
+ let profile_id = business_profile.profile_id.clone();
+ let business_profile = db
+ .insert_business_profile(key_manager_state, &key_store, business_profile)
+ .await
+ .to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {
+ message: format!("Business Profile with the profile_id {profile_id} already exists"),
+ })
+ .attach_printable("Failed to insert Business profile because of duplication error")?;
+
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+ ))]
if merchant_account.default_profile.is_some() {
let unset_default_profile = domain::MerchantAccountUpdate::UnsetDefaultProfile;
db.update_merchant(
@@ -3372,19 +3621,6 @@ pub async fn create_business_profile(
))
}
-#[cfg(all(
- feature = "v2",
- feature = "merchant_account_v2",
- feature = "business_profile_v2"
-))]
-pub async fn create_business_profile(
- _state: SessionState,
- _request: api::BusinessProfileCreate,
- _merchant_id: &id_type::MerchantId,
-) -> RouterResponse<api_models::admin::BusinessProfileResponse> {
- todo!()
-}
-
pub async fn list_business_profile(
state: SessionState,
merchant_id: id_type::MerchantId,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 32b5cc7d7b..3ce9c9ab5a 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -4034,7 +4034,7 @@ pub async fn list_customer_payment_method(
let intent_fulfillment_time = business_profile
.as_ref()
- .and_then(|b_profile| b_profile.intent_fulfillment_time)
+ .and_then(|b_profile| b_profile.get_order_fulfillment_time())
.unwrap_or(consts::DEFAULT_INTENT_FULFILLMENT_TIME);
let hyperswitch_token_data = pm_list_context
@@ -4307,7 +4307,7 @@ impl SavedPMLPaymentsInfo {
let intent_fulfillment_time = self
.business_profile
.as_ref()
- .and_then(|b_profile| b_profile.intent_fulfillment_time)
+ .and_then(|b_profile| b_profile.get_order_fulfillment_time())
.unwrap_or(consts::DEFAULT_INTENT_FULFILLMENT_TIME);
ParentPaymentMethodToken::create_key_for_token((token, pma.payment_method))
@@ -4513,7 +4513,9 @@ async fn generate_saved_pm_response(
pi.is_connector_agnostic_mit_enabled,
pi.requires_cvv,
pi.off_session_payment_flag,
- pi.business_profile.map(|profile| profile.profile_id),
+ pi.business_profile
+ .as_ref()
+ .map(|profile| profile.profile_id.clone()),
)
})
.unwrap_or((false, false, false, Default::default()));
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 30c0d8a01e..a8ec32cb55 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -4016,7 +4016,7 @@ where
routing_data,
connector_data,
mandate_type,
- business_profile.is_connector_agnostic_mit_enabled.clone(),
+ business_profile.is_connector_agnostic_mit_enabled,
)
.await
}
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 81717b953a..b2ecae090c 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -2146,7 +2146,7 @@ pub async fn store_in_vault_and_generate_ppmt(
});
let intent_fulfillment_time = business_profile
- .and_then(|b_profile| b_profile.intent_fulfillment_time)
+ .and_then(|b_profile| b_profile.get_order_fulfillment_time())
.unwrap_or(consts::DEFAULT_FULFILLMENT_TIME);
if let Some(key_for_hyperswitch_token) = key_for_hyperswitch_token {
diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rs
index 3775c8b4e2..2257bd3e01 100644
--- a/crates/router/src/core/payments/types.rs
+++ b/crates/router/src/core/payments/types.rs
@@ -312,7 +312,7 @@ impl SurchargeMetadata {
));
}
let intent_fulfillment_time = business_profile
- .intent_fulfillment_time
+ .get_order_fulfillment_time()
.unwrap_or(router_consts::DEFAULT_FULFILLMENT_TIME);
redis_conn
.set_hash_fields(&redis_key, value_list, Some(intent_fulfillment_time))
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs
index a746f15a98..43da2bb2bd 100644
--- a/crates/router/src/core/routing/helpers.rs
+++ b/crates/router/src/core/routing/helpers.rs
@@ -306,7 +306,7 @@ impl MerchantConnectorAccounts {
where
T: std::hash::Hash + Eq,
{
- self.filter_and_map(|mca| mca.profile_id.as_deref() == Some(profile_id), func)
+ self.filter_and_map(|mca| mca.profile_id == profile_id, func)
}
}
diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs
index 5e3a9c49e8..6feb30a08c 100644
--- a/crates/router/src/routes/admin.rs
+++ b/crates/router/src/routes/admin.rs
@@ -254,7 +254,13 @@ struct HeaderMapStruct<'a> {
#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
impl<'a> HeaderMapStruct<'a> {
- pub fn get_mandatory_header_value_by_key(
+ pub fn from(request: &'a HttpRequest) -> Self {
+ HeaderMapStruct {
+ headers: request.headers(),
+ }
+ }
+
+ fn get_mandatory_header_value_by_key(
&self,
key: String,
) -> Result<&str, error_stack::Report<ApiErrorResponse>> {
@@ -271,6 +277,20 @@ impl<'a> HeaderMapStruct<'a> {
key
))
}
+
+ pub fn get_merchant_id_from_header(
+ &self,
+ ) -> crate::errors::RouterResult<common_utils::id_type::MerchantId> {
+ self.get_mandatory_header_value_by_key(headers::X_MERCHANT_ID.into())
+ .map(|val| val.to_owned())
+ .and_then(|merchant_id| {
+ common_utils::id_type::MerchantId::wrap(merchant_id)
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "Error while converting MerchantId from `x-merchant-id` string header",
+ )
+ })
+ }
}
/// Merchant Connector - Create
@@ -454,25 +474,13 @@ pub async fn connector_retrieve(
let id = path.into_inner();
let payload = web::Json(admin::MerchantConnectorId { id: id.clone() }).into_inner();
- let header_map = HeaderMapStruct {
- headers: req.headers(),
- };
-
- let merchant_id = match header_map
- .get_mandatory_header_value_by_key(headers::X_MERCHANT_ID.into())
- .map(|val| val.to_owned())
- .and_then(|merchant_id| {
- common_utils::id_type::MerchantId::wrap(merchant_id)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable(
- "Error while converting MerchantId from merchant_id string header",
- )
- }) {
+ let merchant_id = match HeaderMapStruct::from(&req).get_merchant_id_from_header() {
Ok(val) => val,
Err(err) => {
return api::log_and_return_error_response(err);
}
};
+
api::server_wrap(
flow,
state,
@@ -734,16 +742,7 @@ pub async fn connector_delete(
let header_map = HeaderMapStruct {
headers: req.headers(),
};
- let merchant_id = match header_map
- .get_mandatory_header_value_by_key(headers::X_MERCHANT_ID.into())
- .map(|val| val.to_owned())
- .and_then(|merchant_id| {
- common_utils::id_type::MerchantId::wrap(merchant_id)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable(
- "Error while converting MerchantId from merchant_id string header",
- )
- }) {
+ let merchant_id = match header_map.get_merchant_id_from_header() {
Ok(val) => val,
Err(err) => {
return api::log_and_return_error_response(err);
@@ -817,6 +816,11 @@ pub async fn merchant_account_toggle_all_kv(
.await
}
+#[cfg(all(
+ feature = "olap",
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+))]
#[instrument(skip_all, fields(flow = ?Flow::BusinessProfileCreate))]
pub async fn business_profile_create(
state: web::Data<AppState>,
@@ -846,6 +850,47 @@ pub async fn business_profile_create(
))
.await
}
+
+#[cfg(all(feature = "olap", feature = "v2", feature = "business_profile_v2"))]
+#[instrument(skip_all, fields(flow = ?Flow::BusinessProfileCreate))]
+pub async fn business_profile_create(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ json_payload: web::Json<admin::BusinessProfileCreate>,
+) -> HttpResponse {
+ let flow = Flow::BusinessProfileCreate;
+ let payload = json_payload.into_inner();
+
+ let merchant_id = match HeaderMapStruct::from(&req).get_merchant_id_from_header() {
+ Ok(val) => val,
+ Err(err) => {
+ return api::log_and_return_error_response(err);
+ }
+ };
+
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ payload,
+ |state, _, req, _| create_business_profile(state, req, &merchant_id),
+ auth::auth_type(
+ &auth::AdminApiAuth,
+ &auth::JWTAuthMerchantFromRoute {
+ merchant_id: merchant_id.clone(),
+ required_permission: Permission::MerchantAccountWrite,
+ },
+ req.headers(),
+ ),
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
+
+#[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "business_profile_v2")
+))]
#[instrument(skip_all, fields(flow = ?Flow::BusinessProfileRetrieve))]
pub async fn business_profile_retrieve(
state: web::Data<AppState>,
@@ -873,6 +918,43 @@ pub async fn business_profile_retrieve(
))
.await
}
+
+#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
+#[instrument(skip_all, fields(flow = ?Flow::BusinessProfileRetrieve))]
+pub async fn business_profile_retrieve(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ path: web::Path<String>,
+) -> HttpResponse {
+ let flow = Flow::BusinessProfileRetrieve;
+ let profile_id = path.into_inner();
+
+ let merchant_id = match HeaderMapStruct::from(&req).get_merchant_id_from_header() {
+ Ok(val) => val,
+ Err(err) => {
+ return api::log_and_return_error_response(err);
+ }
+ };
+
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ profile_id,
+ |state, _, profile_id, _| retrieve_business_profile(state, profile_id, merchant_id.clone()),
+ auth::auth_type(
+ &auth::AdminApiAuth,
+ &auth::JWTAuthMerchantFromRoute {
+ merchant_id: merchant_id.clone(),
+ required_permission: Permission::MerchantAccountRead,
+ },
+ req.headers(),
+ ),
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
+
#[instrument(skip_all, fields(flow = ?Flow::BusinessProfileUpdate))]
pub async fn business_profile_update(
state: web::Data<AppState>,
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 2bb1a5eee8..5fe71a6a8d 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1466,8 +1466,10 @@ impl BusinessProfile {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/profiles")
.app_data(web::Data::new(state))
+ .service(web::resource("").route(web::post().to(business_profile_create)))
.service(
web::scope("/{profile_id}")
+ .service(web::resource("").route(web::get().to(business_profile_retrieve)))
.service(
web::resource("/fallback_routing")
.route(web::get().to(routing::routing_retrieve_default_config))
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index e6266f148f..30edfc187b 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -308,7 +308,7 @@ pub async fn routing_update_default_config(
auth.merchant_account,
auth.key_store,
wrapper.profile_id,
- wrapper.updated_config,
+ wrapper.connectors,
)
},
#[cfg(not(feature = "release"))]
diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs
index 56a6c4ec2b..eb56e3a1db 100644
--- a/crates/router/src/types/api/admin.rs
+++ b/crates/router/src/types/api/admin.rs
@@ -111,7 +111,7 @@ impl ForeignTryFrom<domain::MerchantAccount> for MerchantAccountResponse {
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
- not(any(feature = "business_profile_v2", feature = "merchant_account_v2",))
+ not(feature = "business_profile_v2")
))]
impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
type Error = error_stack::Report<errors::ParsingError>;
@@ -166,11 +166,7 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
}
}
-#[cfg(all(
- feature = "v2",
- feature = "merchant_account_v2",
- feature = "business_profile_v2"
-))]
+#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
type Error = error_stack::Report<errors::ParsingError>;
@@ -187,9 +183,15 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
})
.transpose()?;
+ let order_fulfillment_time = item
+ .order_fulfillment_time
+ .map(|time| api_models::admin::OrderFulfillmentTime::new(time))
+ .transpose()
+ .change_context(errors::ParsingError::IntegerOverflow)?;
+
Ok(Self {
merchant_id: item.merchant_id,
- profile_id: item.profile_id,
+ id: item.profile_id,
profile_name: item.profile_name,
return_url: item.return_url,
enable_payment_response_hash: item.enable_payment_response_hash,
@@ -197,14 +199,6 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
redirect_to_merchant_with_http_post: item.redirect_to_merchant_with_http_post,
webhook_details: item.webhook_details.map(ForeignInto::foreign_into),
metadata: item.metadata,
- // TODO: Remove routing algorithm from api models of business profile
- routing_algorithm: todo!(),
- intent_fulfillment_time: item.intent_fulfillment_time,
- // TODO: Remove frm algorithm from api models of business profile
- frm_routing_algorithm: todo!(),
- #[cfg(feature = "payouts")]
- // TODO: Remove payout algorithm from api models of business profile
- payout_routing_algorithm: todo!(),
applepay_verified_domains: item.applepay_verified_domains,
payment_link_config: item.payment_link_config.map(ForeignInto::foreign_into),
session_expiry: item.session_expiry,
@@ -223,27 +217,17 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
.collect_billing_details_from_wallet_connector,
is_connector_agnostic_mit_enabled: item.is_connector_agnostic_mit_enabled,
outgoing_webhook_custom_http_headers,
+ order_fulfillment_time,
+ order_fulfillment_time_origin: item.order_fulfillment_time_origin,
})
}
}
-#[cfg(all(
- feature = "v2",
- feature = "merchant_account_v2",
- feature = "business_profile_v2"
-))]
-pub async fn create_business_profile(
- _state: &SessionState,
- _request: BusinessProfileCreate,
- _key_store: &MerchantKeyStore,
-) -> Result<domain::BusinessProfile, error_stack::Report<errors::ApiErrorResponse>> {
- todo!()
-}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(any(feature = "merchant_account_v2", feature = "business_profile_v2"))
))]
-pub async fn create_business_profile(
+pub async fn create_business_profile_from_merchant_account(
state: &SessionState,
merchant_account: domain::MerchantAccount,
request: BusinessProfileCreate,
@@ -266,7 +250,7 @@ pub async fn create_business_profile(
.or(merchant_account.payment_response_hash_key)
.unwrap_or(common_utils::crypto::generate_cryptographically_secure_random_string(64));
- let payment_link_config_value = request.payment_link_config.map(ForeignInto::foreign_into);
+ let payment_link_config = request.payment_link_config.map(ForeignInto::foreign_into);
let outgoing_webhook_custom_http_headers = request
.outgoing_webhook_custom_http_headers
.async_map(|headers| {
@@ -325,7 +309,7 @@ pub async fn create_business_profile(
payout_routing_algorithm: None,
is_recon_enabled: merchant_account.is_recon_enabled,
applepay_verified_domains: request.applepay_verified_domains,
- payment_link_config: payment_link_config_value,
+ payment_link_config,
session_expiry: request
.session_expiry
.map(i64::from)
diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs
index f4e4257c02..94405a0249 100644
--- a/crates/storage_impl/src/payouts/payouts.rs
+++ b/crates/storage_impl/src/payouts/payouts.rs
@@ -700,8 +700,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {
})
}
- #[cfg(feature = "olap")]
- #[cfg(all(feature = "v2", feature = "customer_v2"))]
+ #[cfg(all(feature = "olap", feature = "v2", feature = "customer_v2"))]
#[instrument(skip_all)]
async fn filter_payouts_and_attempts(
&self,
@@ -765,7 +764,11 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {
})
}
- #[cfg(feature = "olap")]
+ #[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ feature = "olap",
+ not(feature = "customer_v2")
+ ))]
#[instrument(skip_all)]
async fn filter_active_payout_ids_by_constraints(
&self,
@@ -841,6 +844,16 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {
.into()
})
}
+
+ #[cfg(all(feature = "olap", feature = "v2", feature = "customer_v2"))]
+ #[instrument(skip_all)]
+ async fn filter_active_payout_ids_by_constraints(
+ &self,
+ merchant_id: &common_utils::id_type::MerchantId,
+ constraints: &PayoutFetchConstraints,
+ ) -> error_stack::Result<Vec<String>, StorageError> {
+ todo!()
+ }
}
impl DataModelExt for Payouts {
diff --git a/justfile b/justfile
index c3cea28c67..ab50ec0301 100644
--- a/justfile
+++ b/justfile
@@ -63,6 +63,21 @@ check_v2 *FLAGS:
cargo check {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}
set +x
+run_v2:
+ #! /usr/bin/env bash
+ set -euo pipefail
+
+ FEATURES="$(cargo metadata --all-features --format-version 1 --no-deps | \
+ jq -r '
+ [ .packages[] | select(.name == "router") | .features | keys[] # Obtain features of `router` package
+ | select( any( . ; test("(([a-z_]+)_)?v2") ) ) ] # Select v2 features
+ | join(",") # Construct a comma-separated string of features for passing to `cargo`
+ ')"
+
+ set -x
+ cargo run --package router --features "${FEATURES}"
+ set +x
+
check *FLAGS:
#! /usr/bin/env bash
set -euo pipefail
diff --git a/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/down.sql b/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/down.sql
index 94c02697c5..8d02eca538 100644
--- a/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/down.sql
+++ b/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/down.sql
@@ -1,22 +1,17 @@
-- This adds back dropped columns in `up.sql`.
-- However, if the old columns were dropped, then we won't have data previously
-- stored in these columns.
-ALTER TABLE
- business_profile
-ADD
- COLUMN routing_algorithm JSON DEFAULT NULL,
- -- ADD COLUMN intent_fulfillment_time BIGINT DEFAULT NULL,
-ADD
- COLUMN frm_routing_algorithm JSONB DEFAULT NULL,
-ADD
- COLUMN payout_routing_algorithm JSONB DEFAULT NULL;
+ALTER TABLE business_profile
+ADD COLUMN routing_algorithm JSON DEFAULT NULL,
+ ADD COLUMN intent_fulfillment_time BIGINT DEFAULT NULL,
+ ADD COLUMN frm_routing_algorithm JSONB DEFAULT NULL,
+ ADD COLUMN payout_routing_algorithm JSONB DEFAULT NULL;
-ALTER TABLE
- business_profile DROP COLUMN routing_algorithm_id,
- -- DROP COLUMN order_fulfillment_time,
- -- DROP COLUMN order_fulfillment_time_origin,
+ALTER TABLE business_profile DROP COLUMN routing_algorithm_id,
+ DROP COLUMN order_fulfillment_time,
+ DROP COLUMN order_fulfillment_time_origin,
DROP COLUMN frm_routing_algorithm_id,
DROP COLUMN payout_routing_algorithm_id,
DROP COLUMN default_fallback_routing;
--- DROP TYPE "OrderFulfillmentTimeOrigin";
\ No newline at end of file
+DROP TYPE "OrderFulfillmentTimeOrigin";
diff --git a/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/up.sql b/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/up.sql
index d2275ad236..6f65cf0199 100644
--- a/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/up.sql
+++ b/v2_migrations/2024-07-31-100300_business_profile_add_v2_columns_drop_v1_columns/up.sql
@@ -1,21 +1,16 @@
--- CREATE TYPE "OrderFulfillmentTimeOrigin" AS ENUM ('create', 'confirm');
-ALTER TABLE
- business_profile
-ADD
- COLUMN routing_algorithm_id VARCHAR(64) DEFAULT NULL,
- -- ADD COLUMN order_fulfillment_time BIGINT DEFAULT NULL,
- -- ADD COLUMN order_fulfillment_time_origin "OrderFulfillmentTimeOrigin" DEFAULT NULL,
-ADD
- COLUMN frm_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
-ADD
- COLUMN payout_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
-ADD
- COLUMN default_fallback_routing JSONB DEFAULT NULL;
+CREATE TYPE "OrderFulfillmentTimeOrigin" AS ENUM ('create', 'confirm');
+
+ALTER TABLE business_profile
+ADD COLUMN routing_algorithm_id VARCHAR(64) DEFAULT NULL,
+ ADD COLUMN order_fulfillment_time BIGINT DEFAULT NULL,
+ ADD COLUMN order_fulfillment_time_origin "OrderFulfillmentTimeOrigin" DEFAULT NULL,
+ ADD COLUMN frm_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
+ ADD COLUMN payout_routing_algorithm_id VARCHAR(64) DEFAULT NULL,
+ ADD COLUMN default_fallback_routing JSONB DEFAULT NULL;
-- Note: This query should not be run on higher environments as this leads to data loss.
-- The application will work fine even without these queries being run.
-ALTER TABLE
- business_profile DROP COLUMN routing_algorithm,
- -- DROP COLUMN intent_fulfillment_time,
+ALTER TABLE business_profile DROP COLUMN routing_algorithm,
+ DROP COLUMN intent_fulfillment_time,
DROP COLUMN frm_routing_algorithm,
- DROP COLUMN payout_routing_algorithm;
\ No newline at end of file
+ DROP COLUMN payout_routing_algorithm;