fix(router): Payment link api contract change (#2975)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Kashif <mohammed.kashif@juspay.in>
Co-authored-by: Kashif <kashif.dev@protonmail.com>
Co-authored-by: hrithikeshvm <hrithikeshmylatty@gmail.com>
Co-authored-by: hrithikeshvm <vmhrithikesh@gmail.com>
This commit is contained in:
Sahkal Poddar
2024-01-08 17:40:56 +05:30
committed by GitHub
parent bfd8a5a31a
commit 3cd74966b2
44 changed files with 1653 additions and 814 deletions

View File

@ -95,15 +95,8 @@ pub struct MerchantAccountCreate {
#[schema(value_type = Option<Object>,example = json!({"type": "single", "data": "signifyd"}))]
pub frm_routing_algorithm: Option<serde_json::Value>,
///Will be used to expire client secret after certain amount of time to be supplied in seconds
///(900) for 15 mins
#[schema(example = 900)]
pub intent_fulfillment_time: Option<u32>,
/// The id of the organization to which the merchant belongs to
pub organization_id: Option<String>,
pub payment_link_config: Option<PaymentLinkConfig>,
}
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
@ -185,16 +178,10 @@ pub struct MerchantAccountUpdate {
#[schema(value_type = Option<Object>,example = json!({"type": "single", "data": "signifyd"}))]
pub frm_routing_algorithm: Option<serde_json::Value>,
///Will be used to expire client secret after certain amount of time to be supplied in seconds
///(900) for 15 mins
pub intent_fulfillment_time: Option<u32>,
/// The default business profile that must be used for creating merchant accounts and payments
/// To unset this field, pass an empty string
#[schema(max_length = 64)]
pub default_profile: Option<String>,
pub payment_link_config: Option<serde_json::Value>,
}
#[derive(Clone, Debug, ToSchema, Serialize)]
@ -288,8 +275,6 @@ pub struct MerchantAccountResponse {
/// A enum value to indicate the status of recon service. By default it is not_requested.
#[schema(value_type = ReconStatus, example = "not_requested")]
pub recon_status: enums::ReconStatus,
pub payment_link_config: Option<serde_json::Value>,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
@ -460,26 +445,6 @@ pub struct PrimaryBusinessDetails {
pub business: String,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PaymentLinkConfig {
#[schema(
max_length = 255,
max_length = 255,
example = "https://i.imgur.com/RfxPFQo.png"
)]
pub merchant_logo: Option<String>,
pub color_scheme: Option<PaymentLinkColorSchema>,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PaymentLinkColorSchema {
pub background_primary_color: Option<String>,
pub sdk_theme: Option<String>,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
#[serde(deny_unknown_fields)]
pub struct WebhookDetails {
@ -1048,6 +1013,13 @@ pub struct BusinessProfileCreate {
/// Verified applepay 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>,
}
#[derive(Clone, Debug, ToSchema, Serialize)]
@ -1112,6 +1084,13 @@ pub struct BusinessProfileResponse {
/// Verified applepay 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
pub payment_link_config: Option<serde_json::Value>,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
@ -1169,4 +1148,41 @@ pub struct BusinessProfileUpdate {
/// Verified applepay 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>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct BusinessPaymentLinkConfig {
pub domain_name: Option<String>,
#[serde(flatten)]
pub config: PaymentLinkConfigRequest,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentLinkConfigRequest {
/// custom theme for the payment link
#[schema(value_type = Option<String>, max_length = 255, example = "#4E6ADD")]
pub theme: Option<String>,
/// merchant display logo
#[schema(value_type = Option<String>, max_length = 255, example = "https://i.pinimg.com/736x/4d/83/5c/4d835ca8aafbbb15f84d07d926fda473.jpg")]
pub logo: Option<String>,
/// Custom merchant name for payment link
#[schema(value_type = Option<String>, max_length = 255, example = "hyperswitch")]
pub seller_name: Option<String>,
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, ToSchema)]
pub struct PaymentLinkConfig {
/// custom theme for the payment link
pub theme: String,
/// merchant display logo
pub logo: String,
/// Custom merchant name for payment link
pub seller_name: String,
}

View File

@ -296,8 +296,14 @@ pub struct PaymentsRequest {
/// additional data that might be required by hyperswitch
pub feature_metadata: Option<FeatureMetadata>,
/// payment link object required for generating the payment_link
pub payment_link_object: Option<PaymentLinkObject>,
/// Whether to get the payment link (if applicable)
#[schema(default = false, example = true)]
pub payment_link: Option<bool>,
/// custom payment link config for the particular payment
#[schema(value_type = Option<PaymentCreatePaymentLinkConfig>)]
pub payment_link_config: Option<PaymentCreatePaymentLinkConfig>,
/// The business profile to use for this payment, if not passed the default business profile
/// associated with the merchant account will be used.
@ -314,6 +320,11 @@ pub struct PaymentsRequest {
///Request for an incremental authorization
pub request_incremental_authorization: Option<bool>,
///Will be used to expire client secret after certain amount of time to be supplied in seconds
///(900) for 15 mins
#[schema(example = 900)]
pub session_expiry: Option<u32>,
/// additional data related to some frm connectors
pub frm_metadata: Option<serde_json::Value>,
}
@ -3309,17 +3320,6 @@ mod tests {
}
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentLinkObject {
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub link_expiry: Option<PrimitiveDateTime>,
pub merchant_custom_domain_name: Option<String>,
#[schema(value_type = PaymentLinkConfig)]
pub payment_link_config: Option<admin::PaymentLinkConfig>,
/// Custom merchant name for payment link
pub custom_merchant_name: Option<String>,
}
#[derive(Default, Debug, serde::Deserialize, Clone, ToSchema, serde::Serialize)]
pub struct RetrievePaymentLinkRequest {
pub client_secret: Option<String>,
@ -3339,10 +3339,10 @@ pub struct RetrievePaymentLinkResponse {
pub amount: i64,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub created_at: PrimitiveDateTime,
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub link_expiry: Option<PrimitiveDateTime>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub expiry: Option<PrimitiveDateTime>,
pub description: Option<String>,
pub status: String,
pub status: PaymentLinkStatus,
#[schema(value_type = Option<Currency>)]
pub currency: Option<api_enums::Currency>,
}
@ -3360,14 +3360,15 @@ pub struct PaymentLinkDetails {
pub pub_key: String,
pub client_secret: String,
pub payment_id: String,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub expiry: Option<PrimitiveDateTime>,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub session_expiry: PrimitiveDateTime,
pub merchant_logo: String,
pub return_url: String,
pub merchant_name: String,
pub order_details: Option<Vec<OrderDetailsWithStringAmount>>,
pub max_items_visible_after_collapse: i8,
pub sdk_theme: Option<String>,
pub theme: String,
pub merchant_description: Option<String>,
}
#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]
@ -3424,6 +3425,13 @@ pub struct PaymentLinkListResponse {
pub data: Vec<PaymentLinkResponse>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentCreatePaymentLinkConfig {
#[serde(flatten)]
#[schema(value_type = Option<PaymentLinkConfigRequest>)]
pub config: admin::PaymentLinkConfigRequest,
}
#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct OrderDetailsWithStringAmount {
/// Name of the product that is being purchased
@ -3437,3 +3445,9 @@ pub struct OrderDetailsWithStringAmount {
/// Product Image link
pub product_img_link: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub enum PaymentLinkStatus {
Active,
Expired,
}