mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
Feat(connector): [BRAINTREE] Implement Card Mandates (#5204)
This commit is contained in:
@ -610,6 +610,21 @@ pub async fn get_token_pm_type_mandate_details(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
let payment_method_info = payment_method_id
|
||||
.async_map(|payment_method_id| async move {
|
||||
state
|
||||
.store
|
||||
.find_payment_method(
|
||||
&payment_method_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
.await
|
||||
.to_not_found_response(
|
||||
errors::ApiErrorResponse::PaymentMethodNotFound,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.transpose()?;
|
||||
(
|
||||
request.payment_token.to_owned(),
|
||||
request.payment_method,
|
||||
@ -617,7 +632,7 @@ pub async fn get_token_pm_type_mandate_details(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
payment_method_info,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,10 @@ use crate::{
|
||||
core::{
|
||||
errors::{self, CustomResult, RouterResult, StorageErrorExt},
|
||||
mandate::helpers as m_helpers,
|
||||
payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData},
|
||||
payments::{
|
||||
self, helpers, operations, CustomerAcceptance, CustomerDetails, PaymentAddress,
|
||||
PaymentData,
|
||||
},
|
||||
utils as core_utils,
|
||||
},
|
||||
db::StorageInterface,
|
||||
@ -86,7 +89,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
|
||||
})?;
|
||||
|
||||
let recurring_details = request.recurring_details.clone();
|
||||
let customer_acceptance = request.customer_acceptance.clone().map(From::from);
|
||||
|
||||
payment_attempt = db
|
||||
.find_payment_attempt_by_payment_id_merchant_id_attempt_id(
|
||||
@ -127,6 +129,19 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
|
||||
&payment_intent.customer_id,
|
||||
)
|
||||
.await?;
|
||||
let customer_acceptance: Option<CustomerAcceptance> = request
|
||||
.customer_acceptance
|
||||
.clone()
|
||||
.map(From::from)
|
||||
.or(payment_method_info
|
||||
.clone()
|
||||
.map(|pm| {
|
||||
pm.customer_acceptance
|
||||
.parse_value::<CustomerAcceptance>("CustomerAcceptance")
|
||||
})
|
||||
.transpose()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to deserialize to CustomerAcceptance")?);
|
||||
let token = token.or_else(|| payment_attempt.payment_token.clone());
|
||||
|
||||
if let Some(payment_method) = payment_method {
|
||||
|
||||
@ -1790,6 +1790,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
|
||||
connector_meta: payment_data.payment_attempt.connector_metadata,
|
||||
complete_authorize_url,
|
||||
metadata: payment_data.payment_intent.metadata,
|
||||
customer_acceptance: payment_data.customer_acceptance,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user