mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(connector): Added recurring payments support for split payments in Stripe (#8271)
Co-authored-by: Sayak Bhattacharya <sayak.b@Sayak-Bhattacharya-G092THXJ34.local>
This commit is contained in:
@ -2,7 +2,7 @@ use std::{fmt::Debug, marker::PhantomData, str::FromStr};
|
||||
|
||||
use api_models::payments::{
|
||||
Address, ConnectorMandateReferenceId, CustomerDetails, CustomerDetailsResponse, FrmMessage,
|
||||
RequestSurchargeDetails,
|
||||
MandateIds, RequestSurchargeDetails,
|
||||
};
|
||||
use common_enums::{Currency, RequestIncrementalAuthorization};
|
||||
use common_utils::{
|
||||
@ -3388,6 +3388,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
|
||||
}
|
||||
}
|
||||
|
||||
fn get_off_session(
|
||||
mandate_id: Option<&MandateIds>,
|
||||
off_session_flag: Option<bool>,
|
||||
) -> Option<bool> {
|
||||
match (mandate_id, off_session_flag) {
|
||||
(_, Some(false)) => Some(false),
|
||||
(Some(_), _) | (_, Some(true)) => Some(true),
|
||||
(None, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizeData {
|
||||
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
||||
@ -3542,12 +3553,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
|
||||
})
|
||||
.transpose()?
|
||||
.map(pii::SecretSerdeValue::new);
|
||||
let is_off_session = get_off_session(
|
||||
payment_data.mandate_id.as_ref(),
|
||||
payment_data.payment_intent.off_session,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
|
||||
setup_future_usage: payment_data.payment_attempt.setup_future_usage_applied,
|
||||
mandate_id: payment_data.mandate_id.clone(),
|
||||
off_session: payment_data.mandate_id.as_ref().map(|_| true),
|
||||
off_session: is_off_session,
|
||||
setup_mandate_details: payment_data.setup_mandate.clone(),
|
||||
confirm: payment_data.payment_attempt.confirm,
|
||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||
@ -4385,6 +4400,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
|
||||
.transpose()?
|
||||
.map(pii::SecretSerdeValue::new);
|
||||
|
||||
let is_off_session = get_off_session(
|
||||
payment_data.mandate_id.as_ref(),
|
||||
payment_data.payment_intent.off_session,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
currency: payment_data.currency,
|
||||
confirm: true,
|
||||
@ -4395,7 +4415,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
|
||||
.get_required_value("payment_method_data")?),
|
||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||
setup_future_usage: payment_data.payment_attempt.setup_future_usage_applied,
|
||||
off_session: payment_data.mandate_id.as_ref().map(|_| true),
|
||||
off_session: is_off_session,
|
||||
mandate_id: payment_data.mandate_id.clone(),
|
||||
setup_mandate_details: payment_data.setup_mandate,
|
||||
customer_acceptance: payment_data.customer_acceptance,
|
||||
@ -4529,10 +4549,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
|
||||
.and_then(|braintree| braintree.merchant_account_id.clone());
|
||||
let merchant_config_currency =
|
||||
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
|
||||
|
||||
let is_off_session = get_off_session(
|
||||
payment_data.mandate_id.as_ref(),
|
||||
payment_data.payment_intent.off_session,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
setup_future_usage: payment_data.payment_intent.setup_future_usage,
|
||||
mandate_id: payment_data.mandate_id.clone(),
|
||||
off_session: payment_data.mandate_id.as_ref().map(|_| true),
|
||||
off_session: is_off_session,
|
||||
setup_mandate_details: payment_data.setup_mandate.clone(),
|
||||
confirm: payment_data.payment_attempt.confirm,
|
||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||
|
||||
Reference in New Issue
Block a user