mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +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:
@ -1999,7 +1999,15 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest
|
|||||||
customer: Some(Secret::new(customer_id)),
|
customer: Some(Secret::new(customer_id)),
|
||||||
setup_mandate_details,
|
setup_mandate_details,
|
||||||
off_session: item.request.off_session,
|
off_session: item.request.off_session,
|
||||||
setup_future_usage,
|
setup_future_usage: match (
|
||||||
|
item.request.split_payments.as_ref(),
|
||||||
|
item.request.setup_future_usage,
|
||||||
|
item.request.customer_acceptance.as_ref(),
|
||||||
|
) {
|
||||||
|
(Some(_), Some(usage), Some(_)) => Some(usage),
|
||||||
|
_ => setup_future_usage,
|
||||||
|
},
|
||||||
|
|
||||||
payment_method_types,
|
payment_method_types,
|
||||||
expand: Some(ExpandableObjects::LatestCharge),
|
expand: Some(ExpandableObjects::LatestCharge),
|
||||||
browser_info,
|
browser_info,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use std::{fmt::Debug, marker::PhantomData, str::FromStr};
|
|||||||
|
|
||||||
use api_models::payments::{
|
use api_models::payments::{
|
||||||
Address, ConnectorMandateReferenceId, CustomerDetails, CustomerDetailsResponse, FrmMessage,
|
Address, ConnectorMandateReferenceId, CustomerDetails, CustomerDetailsResponse, FrmMessage,
|
||||||
RequestSurchargeDetails,
|
MandateIds, RequestSurchargeDetails,
|
||||||
};
|
};
|
||||||
use common_enums::{Currency, RequestIncrementalAuthorization};
|
use common_enums::{Currency, RequestIncrementalAuthorization};
|
||||||
use common_utils::{
|
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")))]
|
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||||
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizeData {
|
impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizeData {
|
||||||
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
type Error = error_stack::Report<errors::ApiErrorResponse>;
|
||||||
@ -3542,12 +3553,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
|
|||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(pii::SecretSerdeValue::new);
|
.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 {
|
Ok(Self {
|
||||||
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
|
payment_method_data: (payment_method_data.get_required_value("payment_method_data")?),
|
||||||
setup_future_usage: payment_data.payment_attempt.setup_future_usage_applied,
|
setup_future_usage: payment_data.payment_attempt.setup_future_usage_applied,
|
||||||
mandate_id: payment_data.mandate_id.clone(),
|
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(),
|
setup_mandate_details: payment_data.setup_mandate.clone(),
|
||||||
confirm: payment_data.payment_attempt.confirm,
|
confirm: payment_data.payment_attempt.confirm,
|
||||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||||
@ -4385,6 +4400,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
|
|||||||
.transpose()?
|
.transpose()?
|
||||||
.map(pii::SecretSerdeValue::new);
|
.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 {
|
Ok(Self {
|
||||||
currency: payment_data.currency,
|
currency: payment_data.currency,
|
||||||
confirm: true,
|
confirm: true,
|
||||||
@ -4395,7 +4415,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
|
|||||||
.get_required_value("payment_method_data")?),
|
.get_required_value("payment_method_data")?),
|
||||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||||
setup_future_usage: payment_data.payment_attempt.setup_future_usage_applied,
|
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(),
|
mandate_id: payment_data.mandate_id.clone(),
|
||||||
setup_mandate_details: payment_data.setup_mandate,
|
setup_mandate_details: payment_data.setup_mandate,
|
||||||
customer_acceptance: payment_data.customer_acceptance,
|
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());
|
.and_then(|braintree| braintree.merchant_account_id.clone());
|
||||||
let merchant_config_currency =
|
let merchant_config_currency =
|
||||||
braintree_metadata.and_then(|braintree| braintree.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 {
|
Ok(Self {
|
||||||
setup_future_usage: payment_data.payment_intent.setup_future_usage,
|
setup_future_usage: payment_data.payment_intent.setup_future_usage,
|
||||||
mandate_id: payment_data.mandate_id.clone(),
|
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(),
|
setup_mandate_details: payment_data.setup_mandate.clone(),
|
||||||
confirm: payment_data.payment_attempt.confirm,
|
confirm: payment_data.payment_attempt.confirm,
|
||||||
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
|
||||||
|
|||||||
Reference in New Issue
Block a user