mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +08:00
feat(core): Hyperswitch <|> UCS Mandate flow integration (#8738)
Co-authored-by: Aishwariyaa Anand <aishwariyaa.anand@Aishwariyaa-Anand-C3PGW02T6Y.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
20049d52fa
commit
f94f39ef0c
@ -88,6 +88,14 @@ pub enum UnifiedConnectorServiceError {
|
||||
/// Failed to perform Payment Get from gRPC Server
|
||||
#[error("Failed to perform Payment Get from gRPC Server")]
|
||||
PaymentGetFailure,
|
||||
|
||||
/// Failed to perform Payment Setup Mandate from gRPC Server
|
||||
#[error("Failed to perform Setup Mandate from gRPC Server")]
|
||||
PaymentRegisterFailure,
|
||||
|
||||
/// Failed to perform Payment Repeat Payment from gRPC Server
|
||||
#[error("Failed to perform Repeat Payment from gRPC Server")]
|
||||
PaymentRepeatEverythingFailure,
|
||||
}
|
||||
|
||||
/// Result type for Dynamic Routing
|
||||
@ -160,7 +168,10 @@ impl UnifiedConnectorServiceClient {
|
||||
.await;
|
||||
|
||||
match connect_result {
|
||||
Ok(Ok(client)) => Some(Self { client }),
|
||||
Ok(Ok(client)) => {
|
||||
logger::info!("Successfully connected to Unified Connector Service");
|
||||
Some(Self { client })
|
||||
}
|
||||
Ok(Err(err)) => {
|
||||
logger::error!(error = ?err, "Failed to connect to Unified Connector Service");
|
||||
None
|
||||
@ -217,6 +228,51 @@ impl UnifiedConnectorServiceClient {
|
||||
.change_context(UnifiedConnectorServiceError::PaymentGetFailure)
|
||||
.inspect_err(|error| logger::error!(?error))
|
||||
}
|
||||
|
||||
/// Performs Payment Setup Mandate
|
||||
pub async fn payment_setup_mandate(
|
||||
&self,
|
||||
payment_register_request: payments_grpc::PaymentServiceRegisterRequest,
|
||||
connector_auth_metadata: ConnectorAuthMetadata,
|
||||
grpc_headers: GrpcHeaders,
|
||||
) -> UnifiedConnectorServiceResult<tonic::Response<payments_grpc::PaymentServiceRegisterResponse>>
|
||||
{
|
||||
let mut request = tonic::Request::new(payment_register_request);
|
||||
|
||||
let metadata =
|
||||
build_unified_connector_service_grpc_headers(connector_auth_metadata, grpc_headers)?;
|
||||
*request.metadata_mut() = metadata;
|
||||
|
||||
self.client
|
||||
.clone()
|
||||
.register(request)
|
||||
.await
|
||||
.change_context(UnifiedConnectorServiceError::PaymentRegisterFailure)
|
||||
.inspect_err(|error| logger::error!(?error))
|
||||
}
|
||||
|
||||
/// Performs Payment repeat (MIT - Merchant Initiated Transaction).
|
||||
pub async fn payment_repeat(
|
||||
&self,
|
||||
payment_repeat_request: payments_grpc::PaymentServiceRepeatEverythingRequest,
|
||||
connector_auth_metadata: ConnectorAuthMetadata,
|
||||
grpc_headers: GrpcHeaders,
|
||||
) -> UnifiedConnectorServiceResult<
|
||||
tonic::Response<payments_grpc::PaymentServiceRepeatEverythingResponse>,
|
||||
> {
|
||||
let mut request = tonic::Request::new(payment_repeat_request);
|
||||
|
||||
let metadata =
|
||||
build_unified_connector_service_grpc_headers(connector_auth_metadata, grpc_headers)?;
|
||||
*request.metadata_mut() = metadata;
|
||||
|
||||
self.client
|
||||
.clone()
|
||||
.repeat_everything(request)
|
||||
.await
|
||||
.change_context(UnifiedConnectorServiceError::PaymentRepeatEverythingFailure)
|
||||
.inspect_err(|error| logger::error!(?error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the gRPC Headers for Unified Connector Service Request
|
||||
|
||||
Reference in New Issue
Block a user