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(api_models/connector): [SANTANDER] Add boleto related fields in feature metadata (#12683)

Sayak Bhattacharya4ce8ca471a7a
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 13cfac7f50..e244248f4d 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -14228,6 +14228,46 @@
}
],
"nullable": true
+ },
+ "discount_rules": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SantanderPaymentDiscountRules"
+ }
+ ],
+ "nullable": true
+ },
+ "penalties": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PenaltyRules"
+ }
+ ],
+ "nullable": true
+ },
+ "collection_actions": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CollectionActions"
+ }
+ ],
+ "nullable": true
+ },
+ "payment_constraints": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BoletoPaymentTypeConstraints"
+ }
+ ],
+ "nullable": true
+ },
+ "beneficiary": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BeneficiaryDetails"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 11622b2003..5e4ae031f3 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -9631,6 +9631,46 @@
}
],
"nullable": true
+ },
+ "discount_rules": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/SantanderPaymentDiscountRules"
+ }
+ ],
+ "nullable": true
+ },
+ "penalties": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PenaltyRules"
+ }
+ ],
+ "nullable": true
+ },
+ "collection_actions": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CollectionActions"
+ }
+ ],
+ "nullable": true
+ },
+ "payment_constraints": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BoletoPaymentTypeConstraints"
+ }
+ ],
+ "nullable": true
+ },
+ "beneficiary": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BeneficiaryDetails"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index ff1fe2b340..7b64c4f29f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -11724,7 +11724,7 @@ pub struct BoletoAdditionalDetails {
pub due_date: Option<PrimitiveDateTime>,
/// It tells the bank what type of commercial document created the boleto. Why does this boleto exist? What kind of transaction or contract caused it?
/// Deprecated since it has been moved to connector_metadata
- #[schema(value_type = Option<BoletoDocumentKind>, example="commercial_invoice", deprecated)]
+ #[schema(value_type = Option<BoletoDocumentKind>, example="commercial_invoice")]
pub document_kind: Option<common_enums::BoletoDocumentKind>,
/// This field tells the bank how the boleto can be paid — whether the payer must pay the exact amount, can pay a different amount, or pay in parts.
/// Deprecated since it has been moved to connector_metadata
@@ -11741,6 +11741,25 @@ pub struct BoletoAdditionalDetails {
})
)]
pub pix_key: Option<enums::PixKey>,
+ /// Rules for applying discounts
+ #[schema(value_type = Option<SantanderPaymentDiscountRules>)]
+ #[serde(default)]
+ pub discount_rules: Option<SantanderPaymentDiscountRules>,
+ /// Rules for late payments (Interest and Fines)
+ #[schema(value_type = Option<PenaltyRules>)]
+ #[serde(default)]
+ pub penalties: Option<PenaltyRules>,
+ /// Legal or administrative actions for non-payment (Protest/Write-off)
+ #[schema(value_type = Option<CollectionActions>)]
+ #[serde(default)]
+ pub collection_actions: Option<CollectionActions>,
+ /// Constraints on how the payment can be made (Partial payments/Limits)
+ #[schema(value_type = Option<BoletoPaymentTypeConstraints>)]
+ #[serde(default)]
+ pub payment_constraints: Option<BoletoPaymentTypeConstraints>,
+ #[schema(value_type = Option<BeneficiaryDetails>)]
+ #[serde(default)]
+ pub beneficiary: Option<BeneficiaryDetails>,
}
impl BoletoAdditionalDetails {
@@ -11751,6 +11770,11 @@ impl BoletoAdditionalDetails {
payment_type: self.payment_type.or(other.payment_type),
covenant_code: self.covenant_code.or(other.covenant_code),
pix_key: self.pix_key.or(other.pix_key),
+ discount_rules: self.discount_rules.or(other.discount_rules),
+ penalties: self.penalties.or(other.penalties),
+ collection_actions: self.collection_actions.or(other.collection_actions),
+ payment_constraints: self.payment_constraints.or(other.payment_constraints),
+ beneficiary: self.beneficiary.or(other.beneficiary),
}
}
diff --git a/crates/diesel_models/src/types.rs b/crates/diesel_models/src/types.rs
index 4b09669114..d92152884c 100644
--- a/crates/diesel_models/src/types.rs
+++ b/crates/diesel_models/src/types.rs
@@ -2,7 +2,11 @@
use common_enums::enums::PaymentConnectorTransmission;
#[cfg(feature = "v2")]
use common_utils::id_type;
-use common_utils::{hashing::HashedString, pii, types::MinorUnit};
+use common_utils::{
+ hashing::HashedString,
+ pii,
+ types::{MinorUnit, StringMajorUnit},
+};
use diesel::{
sql_types::{Json, Jsonb},
AsExpression, FromSqlRow,
@@ -95,6 +99,149 @@ pub struct BoletoAdditionalDetails {
pub covenant_code: Option<Secret<String>>,
/// Pix identification details
pub pix_key: Option<common_enums::enums::PixKey>,
+ /// Rules for applying discounts
+ pub discount_rules: Option<SantanderPaymentDiscountRules>,
+ /// Rules for late payments (Interest and Fines)
+ pub penalties: Option<PenaltyRules>,
+ /// Legal or administrative actions for non-payment (Protest/Write-off)
+ pub collection_actions: Option<CollectionActions>,
+ /// Constraints on how the payment can be made (Partial payments/Limits)
+ pub payment_constraints: Option<BoletoPaymentTypeConstraints>,
+ /// Beneficiary details
+ pub beneficiary: Option<BeneficiaryDetails>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct SantanderPaymentDiscountRules {
+ /// Type of discount applied to the payment.
+ pub discount_type: Option<DiscountType>,
+ /// Discount tiers applicable to the payment.
+ pub tiers: Vec<DiscountTier>,
+}
+
+#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum DiscountType {
+ /// No discount logic will be applied.
+ #[default]
+ Standard,
+ /// A fixed amount reduction if paid on or before a specific date.
+ FixedDate,
+ /// A sliding discount calculated per calendar day until the due date.
+ DailyCalendar,
+ /// A sliding discount calculated per business day until the due date.
+ DailyBusiness,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub struct DiscountTier {
+ /// The discount value.
+ pub amount: Option<StringMajorUnit>,
+ /// The ISO-8601 date until which this discount is valid.
+ #[serde(default, with = "common_utils::custom_serde::date_only_optional")]
+ pub end_date: Option<time::PrimitiveDateTime>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct PenaltyRules {
+ /// Fixed fee applied once after the due date.
+ pub fixed_penalty: Option<PenaltyDetail>,
+ /// Recurring cost applied over time.
+ pub interest: Option<InterestDetail>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct InterestDetail {
+ /// Percentage of Juros (Interest).
+ pub interest_percentage: Option<StringMajorUnit>,
+ /// Percentage of IOF (Financial Operations Tax).
+ pub iof_percentage: Option<StringMajorUnit>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct PenaltyDetail {
+ /// The numeric value as a string to preserve decimal precision.
+ pub value: Option<StringMajorUnit>,
+ /// Days after due date before this applies.
+ pub grace_period_days: Option<u32>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct CollectionActions {
+ /// Logic for legal protest.
+ pub legal_protest: Option<ProtestRules>,
+ /// Days after which the bill is automatically cancelled/written off.
+ pub auto_write_off_days: Option<u32>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct ProtestRules {
+ /// The timing logic for when the protest should occur.
+ pub protest_type: Option<ProtestType>,
+ /// Number of days after the due date to initiate the protest.
+ pub days_after_due_date: Option<u32>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum ProtestType {
+ /// No legal protest will be initiated.
+ Disabled,
+ /// Count is based on calendar days.
+ CalendarDays,
+ /// Count is based on business days.
+ BusinessDays,
+ /// Protest logic is handled based on the merchant's bank agreement.
+ ContractDefault,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case", tag = "type", content = "details")]
+pub enum BoletoPaymentTypeConstraints {
+ /// Only the exact nominal amount can be paid.
+ FixedAmount,
+ /// The payer may pay any amount within an allowed range.
+ FlexibleAmount(FlexibleAmountDetails),
+ /// The payer may make multiple payments, up to a specific limit.
+ Installment(InstallmentDetails),
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct FlexibleAmountDetails {
+ /// Minimum value allowed.
+ pub min_value: Option<StringMajorUnit>,
+ /// Maximum value allowed.
+ pub max_value: Option<StringMajorUnit>,
+ /// Defines if the min/max values are percentages or flat amounts.
+ pub value_type: Option<CalculationType>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct InstallmentDetails {
+ /// Maximum number of partial payments allowed.
+ pub max_partial_payments: Option<u32>,
+ /// Defines if the values are percentages or flat amounts.
+ pub value_type: Option<CalculationType>,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum CalculationType {
+ /// The value is treated as a percentage.
+ Percentage,
+ /// The value is treated as a fixed monetary amount.
+ FlatAmount,
+}
+
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
+pub struct BeneficiaryDetails {
+ /// The full legal name of the individual or entity receiving the funds.
+ pub name: Option<String>,
+ /// The customer's unique identification number.
+ pub document_number: Option<String>,
+ /// The category of identification provided.
+ pub document_type: Option<common_types::customers::DocumentKind>,
}
#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize, FromSqlRow, AsExpression)]
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
index fa81182682..92ff6d8b17 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
@@ -1,7 +1,7 @@
use api_models::payments::{
- AccountType, BeneficiaryDetails, BoletoPaymentTypeConstraints, CalculationType,
- ConnectorMetadata, DiscountTier, DiscountType, PollConfig, ProtestType, QrCodeInformation,
- SantanderData, SantanderMandatePeriodicity, SantanderPaymentDiscountRules, VoucherNextStepData,
+ AccountType, BeneficiaryDetails, BoletoPaymentTypeConstraints, CalculationType, DiscountTier,
+ DiscountType, FeatureMetadata, PollConfig, ProtestType, QrCodeInformation, SantanderData,
+ SantanderMandatePeriodicity, SantanderPaymentDiscountRules, VoucherNextStepData,
};
use common_enums::{enums, AttemptStatus, BoletoDocumentKind, ExpiryType, PixKey};
use common_utils::{
@@ -720,12 +720,7 @@ impl
max_value_or_percentage,
),
) = get_boleto_additional_fields_from_connector_metadata(
- value
- .0
- .router_data
- .request
- .connector_intent_metadata
- .clone(),
+ value.0.router_data.request.feature_metadata.clone(),
);
Ok(Self::Boleto(Box::new(SantanderBoletoPaymentRequest {
@@ -1838,7 +1833,7 @@ fn convert_pix_data_to_value(
let qr_code_info = QrCodeInformation::QrCodeUrl {
image_data_url: image_data_url.clone(),
- qr_code_url: None,
+ qr_code_url: Some(image_data_url),
display_to_timestamp: None,
expiry_type: variant,
raw_qr_data: Some(data),
@@ -2198,11 +2193,10 @@ impl From<BoletoPaymentTypeConstraints> for SantanderBoletoPaymentType {
}
fn get_boleto_additional_fields_from_connector_metadata(
- metadata: Option<ConnectorMetadata>,
+ metadata: Option<FeatureMetadata>,
) -> BoletoAdditionalFields {
metadata
- .and_then(|m| m.santander)
- .and_then(|s| s.boleto)
+ .and_then(|m| m.boleto_additional_details)
.map(|b| {
let fine = b.penalties.as_ref().and_then(|p| p.fixed_penalty.as_ref());
let fine_quantity_days = fine.and_then(|f| f.grace_period_days.map(|d| d.to_string()));
diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
index 4884cf5a82..18f2e3443d 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -178,6 +178,21 @@ impl ApiModelToDieselModelConvertor<api_models::payments::BoletoAdditionalDetail
payment_type: from.payment_type,
covenant_code: from.covenant_code,
pix_key: from.pix_key,
+ discount_rules: from
+ .discount_rules
+ .map(diesel_models::types::SantanderPaymentDiscountRules::convert_from),
+ penalties: from
+ .penalties
+ .map(diesel_models::types::PenaltyRules::convert_from),
+ collection_actions: from
+ .collection_actions
+ .map(diesel_models::types::CollectionActions::convert_from),
+ payment_constraints: from
+ .payment_constraints
+ .map(diesel_models::types::BoletoPaymentTypeConstraints::convert_from),
+ beneficiary: from
+ .beneficiary
+ .map(diesel_models::types::BeneficiaryDetails::convert_from),
}
}
@@ -188,6 +203,315 @@ impl ApiModelToDieselModelConvertor<api_models::payments::BoletoAdditionalDetail
payment_type: self.payment_type,
covenant_code: self.covenant_code,
pix_key: self.pix_key,
+ discount_rules: self.discount_rules.map(|value| value.convert_back()),
+ penalties: self.penalties.map(|value| value.convert_back()),
+ collection_actions: self.collection_actions.map(|value| value.convert_back()),
+ payment_constraints: self.payment_constraints.map(|value| value.convert_back()),
+ beneficiary: self.beneficiary.map(|value| value.convert_back()),
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::SantanderPaymentDiscountRules>
+ for diesel_models::types::SantanderPaymentDiscountRules
+{
+ fn convert_from(from: api_models::payments::SantanderPaymentDiscountRules) -> Self {
+ Self {
+ discount_type: from
+ .discount_type
+ .map(diesel_models::types::DiscountType::convert_from),
+ tiers: from
+ .tiers
+ .into_iter()
+ .map(diesel_models::types::DiscountTier::convert_from)
+ .collect(),
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::SantanderPaymentDiscountRules {
+ api_models::payments::SantanderPaymentDiscountRules {
+ discount_type: self.discount_type.map(|value| value.convert_back()),
+ tiers: self
+ .tiers
+ .into_iter()
+ .map(|value| value.convert_back())
+ .collect(),
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::DiscountType>
+ for diesel_models::types::DiscountType
+{
+ fn convert_from(from: api_models::payments::DiscountType) -> Self {
+ match from {
+ api_models::payments::DiscountType::Standard => Self::Standard,
+ api_models::payments::DiscountType::FixedDate => Self::FixedDate,
+ api_models::payments::DiscountType::DailyCalendar => Self::DailyCalendar,
+ api_models::payments::DiscountType::DailyBusiness => Self::DailyBusiness,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::DiscountType {
+ match self {
+ Self::Standard => api_models::payments::DiscountType::Standard,
+ Self::FixedDate => api_models::payments::DiscountType::FixedDate,
+ Self::DailyCalendar => api_models::payments::DiscountType::DailyCalendar,
+ Self::DailyBusiness => api_models::payments::DiscountType::DailyBusiness,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::DiscountTier>
+ for diesel_models::types::DiscountTier
+{
+ fn convert_from(from: api_models::payments::DiscountTier) -> Self {
+ Self {
+ amount: from.amount,
+ end_date: from.end_date,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::DiscountTier {
+ api_models::payments::DiscountTier {
+ amount: self.amount,
+ end_date: self.end_date,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::PenaltyRules>
+ for diesel_models::types::PenaltyRules
+{
+ fn convert_from(from: api_models::payments::PenaltyRules) -> Self {
+ Self {
+ fixed_penalty: from
+ .fixed_penalty
+ .map(diesel_models::types::PenaltyDetail::convert_from),
+ interest: from
+ .interest
+ .map(diesel_models::types::InterestDetail::convert_from),
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::PenaltyRules {
+ api_models::payments::PenaltyRules {
+ fixed_penalty: self.fixed_penalty.map(|value| value.convert_back()),
+ interest: self.interest.map(|value| value.convert_back()),
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::InterestDetail>
+ for diesel_models::types::InterestDetail
+{
+ fn convert_from(from: api_models::payments::InterestDetail) -> Self {
+ Self {
+ interest_percentage: from.interest_percentage,
+ iof_percentage: from.iof_percentage,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::InterestDetail {
+ api_models::payments::InterestDetail {
+ interest_percentage: self.interest_percentage,
+ iof_percentage: self.iof_percentage,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::PenaltyDetail>
+ for diesel_models::types::PenaltyDetail
+{
+ fn convert_from(from: api_models::payments::PenaltyDetail) -> Self {
+ Self {
+ value: from.value,
+ grace_period_days: from.grace_period_days,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::PenaltyDetail {
+ api_models::payments::PenaltyDetail {
+ value: self.value,
+ grace_period_days: self.grace_period_days,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::CollectionActions>
+ for diesel_models::types::CollectionActions
+{
+ fn convert_from(from: api_models::payments::CollectionActions) -> Self {
+ Self {
+ legal_protest: from
+ .legal_protest
+ .map(diesel_models::types::ProtestRules::convert_from),
+ auto_write_off_days: from.auto_write_off_days,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::CollectionActions {
+ api_models::payments::CollectionActions {
+ legal_protest: self.legal_protest.map(|value| value.convert_back()),
+ auto_write_off_days: self.auto_write_off_days,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::ProtestRules>
+ for diesel_models::types::ProtestRules
+{
+ fn convert_from(from: api_models::payments::ProtestRules) -> Self {
+ Self {
+ protest_type: from
+ .protest_type
+ .map(diesel_models::types::ProtestType::convert_from),
+ days_after_due_date: from.days_after_due_date,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::ProtestRules {
+ api_models::payments::ProtestRules {
+ protest_type: self.protest_type.map(|value| value.convert_back()),
+ days_after_due_date: self.days_after_due_date,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::ProtestType>
+ for diesel_models::types::ProtestType
+{
+ fn convert_from(from: api_models::payments::ProtestType) -> Self {
+ match from {
+ api_models::payments::ProtestType::Disabled => Self::Disabled,
+ api_models::payments::ProtestType::CalendarDays => Self::CalendarDays,
+ api_models::payments::ProtestType::BusinessDays => Self::BusinessDays,
+ api_models::payments::ProtestType::ContractDefault => Self::ContractDefault,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::ProtestType {
+ match self {
+ Self::Disabled => api_models::payments::ProtestType::Disabled,
+ Self::CalendarDays => api_models::payments::ProtestType::CalendarDays,
+ Self::BusinessDays => api_models::payments::ProtestType::BusinessDays,
+ Self::ContractDefault => api_models::payments::ProtestType::ContractDefault,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::BoletoPaymentTypeConstraints>
+ for diesel_models::types::BoletoPaymentTypeConstraints
+{
+ fn convert_from(from: api_models::payments::BoletoPaymentTypeConstraints) -> Self {
+ match from {
+ api_models::payments::BoletoPaymentTypeConstraints::FixedAmount => Self::FixedAmount,
+ api_models::payments::BoletoPaymentTypeConstraints::FlexibleAmount(details) => {
+ Self::FlexibleAmount(diesel_models::types::FlexibleAmountDetails::convert_from(
+ details,
+ ))
+ }
+ api_models::payments::BoletoPaymentTypeConstraints::Installment(details) => {
+ Self::Installment(diesel_models::types::InstallmentDetails::convert_from(
+ details,
+ ))
+ }
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::BoletoPaymentTypeConstraints {
+ match self {
+ Self::FixedAmount => api_models::payments::BoletoPaymentTypeConstraints::FixedAmount,
+ Self::FlexibleAmount(details) => {
+ api_models::payments::BoletoPaymentTypeConstraints::FlexibleAmount(
+ details.convert_back(),
+ )
+ }
+ Self::Installment(details) => {
+ api_models::payments::BoletoPaymentTypeConstraints::Installment(
+ details.convert_back(),
+ )
+ }
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::FlexibleAmountDetails>
+ for diesel_models::types::FlexibleAmountDetails
+{
+ fn convert_from(from: api_models::payments::FlexibleAmountDetails) -> Self {
+ Self {
+ min_value: from.min_value,
+ max_value: from.max_value,
+ value_type: from
+ .value_type
+ .map(diesel_models::types::CalculationType::convert_from),
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::FlexibleAmountDetails {
+ api_models::payments::FlexibleAmountDetails {
+ min_value: self.min_value,
+ max_value: self.max_value,
+ value_type: self.value_type.map(|value| value.convert_back()),
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::InstallmentDetails>
+ for diesel_models::types::InstallmentDetails
+{
+ fn convert_from(from: api_models::payments::InstallmentDetails) -> Self {
+ Self {
+ max_partial_payments: from.max_partial_payments,
+ value_type: from
+ .value_type
+ .map(diesel_models::types::CalculationType::convert_from),
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::InstallmentDetails {
+ api_models::payments::InstallmentDetails {
+ max_partial_payments: self.max_partial_payments,
+ value_type: self.value_type.map(|value| value.convert_back()),
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::CalculationType>
+ for diesel_models::types::CalculationType
+{
+ fn convert_from(from: api_models::payments::CalculationType) -> Self {
+ match from {
+ api_models::payments::CalculationType::Percentage => Self::Percentage,
+ api_models::payments::CalculationType::FlatAmount => Self::FlatAmount,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::CalculationType {
+ match self {
+ Self::Percentage => api_models::payments::CalculationType::Percentage,
+ Self::FlatAmount => api_models::payments::CalculationType::FlatAmount,
+ }
+ }
+}
+
+impl ApiModelToDieselModelConvertor<api_models::payments::BeneficiaryDetails>
+ for diesel_models::types::BeneficiaryDetails
+{
+ fn convert_from(from: api_models::payments::BeneficiaryDetails) -> Self {
+ Self {
+ name: from.name,
+ document_number: from.document_number,
+ document_type: from.document_type,
+ }
+ }
+
+ fn convert_back(self) -> api_models::payments::BeneficiaryDetails {
+ api_models::payments::BeneficiaryDetails {
+ name: self.name,
+ document_number: self.document_number,
+ document_type: self.document_type,
}
}
}
diff --git a/crates/router/src/core/revenue_recovery/api.rs b/crates/router/src/core/revenue_recovery/api.rs
index 4f34c7bcb5..af0ee16360 100644
--- a/crates/router/src/core/revenue_recovery/api.rs
+++ b/crates/router/src/core/revenue_recovery/api.rs
@@ -166,7 +166,7 @@ pub async fn update_payment_intent_api(
revenue_recovery_payment_data.key_store.clone(),
None,
);
- let (payment_data, _req, _) = payments::payments_intent_operation_core::<
+ let (payment_data, _req, _) = Box::pin(payments::payments_intent_operation_core::<
api_types::PaymentUpdateIntent,
_,
_,
@@ -180,7 +180,7 @@ pub async fn update_payment_intent_api(
update_req,
global_payment_id,
payments_domain::HeaderPayload::default(),
- )
+ ))
.await?;
Ok(payment_data)
}
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index ea5d8df4c0..23433a8d19 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -793,16 +793,17 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
let conn = pg_connection_write(self).await?;
let diesel_payment_intent_update = PaymentIntentUpdateInternal::try_from(payment_intent)
.change_context(StorageError::DeserializationFailed)?;
- let diesel_payment_intent = this
- .convert()
- .await
- .change_context(StorageError::EncryptionError)?
- .update(&conn, diesel_payment_intent_update)
- .await
- .map_err(|er| {
- let new_err = diesel_error_to_data_error(*er.current_context());
- er.change_context(new_err)
- })?;
+ let diesel_payment_intent = Box::pin(
+ this.convert()
+ .await
+ .change_context(StorageError::EncryptionError)?
+ .update(&conn, diesel_payment_intent_update),
+ )
+ .await
+ .map_err(|er| {
+ let new_err = diesel_error_to_data_error(*er.current_context());
+ er.change_context(new_err)
+ })?;
PaymentIntent::convert_back(
self.get_keymanager_state()