mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
feat(core): accept business profile in core functions for payments, refund, payout and disputes (#5498)
This commit is contained in:
@ -26,6 +26,7 @@ use crate::{
|
||||
pub async fn retrieve_dispute(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
req: disputes::DisputeId,
|
||||
) -> RouterResponse<api_models::disputes::DisputeResponse> {
|
||||
let dispute = state
|
||||
@ -43,6 +44,7 @@ pub async fn retrieve_dispute(
|
||||
pub async fn retrieve_disputes_list(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
constraints: api_models::disputes::DisputeListConstraints,
|
||||
) -> RouterResponse<Vec<api_models::disputes::DisputeResponse>> {
|
||||
let disputes = state
|
||||
@ -62,6 +64,7 @@ pub async fn retrieve_disputes_list(
|
||||
pub async fn accept_dispute(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
req: disputes::DisputeId,
|
||||
) -> RouterResponse<dispute_models::DisputeResponse> {
|
||||
@ -164,6 +167,7 @@ pub async fn accept_dispute(
|
||||
pub async fn submit_evidence(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
req: dispute_models::SubmitEvidenceRequest,
|
||||
) -> RouterResponse<dispute_models::DisputeResponse> {
|
||||
@ -329,6 +333,7 @@ pub async fn submit_evidence(
|
||||
pub async fn attach_evidence(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
attach_evidence_request: api::AttachEvidenceRequest,
|
||||
) -> RouterResponse<files_api_models::CreateFileResponse> {
|
||||
@ -406,6 +411,7 @@ pub async fn attach_evidence(
|
||||
pub async fn retrieve_dispute_evidence(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
req: disputes::DisputeId,
|
||||
) -> RouterResponse<Vec<api_models::disputes::DisputeEvidenceBlock>> {
|
||||
let dispute = state
|
||||
|
||||
@ -215,6 +215,7 @@ impl<F: Send + Clone> Domain<F> for FraudCheckPost {
|
||||
state.clone(),
|
||||
req_state.clone(),
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentCancel,
|
||||
cancel_req,
|
||||
@ -270,6 +271,7 @@ impl<F: Send + Clone> Domain<F> for FraudCheckPost {
|
||||
state.clone(),
|
||||
req_state.clone(),
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentCapture,
|
||||
capture_request,
|
||||
|
||||
@ -788,6 +788,7 @@ pub async fn payments_core<F, Res, Req, Op, FData>(
|
||||
state: SessionState,
|
||||
req_state: ReqState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
operation: Op,
|
||||
req: Req,
|
||||
@ -998,6 +999,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account,
|
||||
None,
|
||||
merchant_key_store,
|
||||
payment_complete_authorize::CompleteAuthorize,
|
||||
payment_confirm_req,
|
||||
@ -1129,6 +1131,7 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account,
|
||||
None,
|
||||
merchant_key_store,
|
||||
PaymentStatus,
|
||||
payment_sync_req,
|
||||
@ -1286,6 +1289,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account,
|
||||
None,
|
||||
merchant_key_store,
|
||||
PaymentConfirm,
|
||||
payment_confirm_req,
|
||||
@ -1316,6 +1320,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
merchant_key_store,
|
||||
PaymentStatus,
|
||||
payment_sync_req,
|
||||
@ -2866,6 +2871,7 @@ pub fn is_operation_complete_authorize<Op: Debug>(operation: &Op) -> bool {
|
||||
pub async fn list_payments(
|
||||
state: SessionState,
|
||||
merchant: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
constraints: api::PaymentListConstraints,
|
||||
) -> RouterResponse<api::PaymentListResponse> {
|
||||
@ -2938,6 +2944,7 @@ pub async fn list_payments(
|
||||
pub async fn apply_filters_on_payments(
|
||||
state: SessionState,
|
||||
merchant: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
merchant_key_store: domain::MerchantKeyStore,
|
||||
constraints: api::PaymentListFilterConstraints,
|
||||
) -> RouterResponse<api::PaymentListResponseV2> {
|
||||
@ -3035,6 +3042,7 @@ pub async fn get_filters_for_payments(
|
||||
pub async fn get_payment_filters(
|
||||
state: SessionState,
|
||||
merchant: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
) -> RouterResponse<api::PaymentListFiltersV2> {
|
||||
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =
|
||||
super::admin::list_payment_connectors(state, merchant.get_id().to_owned()).await?
|
||||
|
||||
@ -482,6 +482,7 @@ pub async fn payouts_update_core(
|
||||
pub async fn payouts_retrieve_core(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
req: payouts::PayoutRetrieveRequest,
|
||||
) -> RouterResponse<payouts::PayoutCreateResponse> {
|
||||
@ -707,6 +708,7 @@ pub async fn payouts_fulfill_core(
|
||||
pub async fn payouts_list_core(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
constraints: payouts::PayoutListConstraints,
|
||||
) -> RouterResponse<payouts::PayoutListResponse> {
|
||||
@ -805,6 +807,7 @@ pub async fn payouts_list_core(
|
||||
pub async fn payouts_filtered_list_core(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
filters: payouts::PayoutListFilterConstraints,
|
||||
) -> RouterResponse<payouts::PayoutListResponse> {
|
||||
|
||||
@ -47,6 +47,7 @@ use crate::{
|
||||
pub async fn refund_create_core(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
req: refunds::RefundRequest,
|
||||
) -> RouterResponse<refunds::RefundResponse> {
|
||||
@ -373,17 +374,24 @@ where
|
||||
pub async fn refund_response_wrapper<'a, F, Fut, T, Req>(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
request: Req,
|
||||
f: F,
|
||||
) -> RouterResponse<refunds::RefundResponse>
|
||||
where
|
||||
F: Fn(SessionState, domain::MerchantAccount, domain::MerchantKeyStore, Req) -> Fut,
|
||||
F: Fn(
|
||||
SessionState,
|
||||
domain::MerchantAccount,
|
||||
Option<String>,
|
||||
domain::MerchantKeyStore,
|
||||
Req,
|
||||
) -> Fut,
|
||||
Fut: futures::Future<Output = RouterResult<T>>,
|
||||
T: ForeignInto<refunds::RefundResponse>,
|
||||
{
|
||||
Ok(services::ApplicationResponse::Json(
|
||||
f(state, merchant_account, key_store, request)
|
||||
f(state, merchant_account, profile_id, key_store, request)
|
||||
.await?
|
||||
.foreign_into(),
|
||||
))
|
||||
@ -393,6 +401,7 @@ where
|
||||
pub async fn refund_retrieve_core(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id: Option<String>,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
request: refunds::RefundsRetrieveRequest,
|
||||
) -> RouterResult<storage::Refund> {
|
||||
@ -856,6 +865,7 @@ pub async fn validate_and_create_refund(
|
||||
pub async fn refund_list(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
req: api_models::refunds::RefundListRequest,
|
||||
) -> RouterResponse<api_models::refunds::RefundListResponse> {
|
||||
let db = state.store;
|
||||
@ -977,6 +987,7 @@ pub async fn refund_manual_update(
|
||||
pub async fn get_filters_for_refunds(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
_profile_id_list: Option<Vec<String>>,
|
||||
) -> RouterResponse<api_models::refunds::RefundListFilters> {
|
||||
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =
|
||||
super::admin::list_payment_connectors(state, merchant_account.get_id().to_owned()).await?
|
||||
@ -1157,6 +1168,7 @@ pub async fn sync_refund_with_gateway_workflow(
|
||||
let response = Box::pin(refund_retrieve_core(
|
||||
state.clone(),
|
||||
merchant_account,
|
||||
None,
|
||||
key_store,
|
||||
refunds::RefundsRetrieveRequest {
|
||||
refund_id: refund_core.refund_internal_reference_id,
|
||||
|
||||
@ -544,6 +544,7 @@ async fn payments_incoming_webhook_flow(
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::operations::PaymentStatus,
|
||||
api::PaymentsRetrieveRequest {
|
||||
@ -824,6 +825,7 @@ async fn refunds_incoming_webhook_flow(
|
||||
Box::pin(refunds::refund_retrieve_core(
|
||||
state.clone(),
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
api_models::refunds::RefundsRetrieveRequest {
|
||||
refund_id: refund_id.to_owned(),
|
||||
@ -1075,6 +1077,7 @@ async fn external_authentication_incoming_webhook_flow(
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentConfirm,
|
||||
payment_confirm_req,
|
||||
@ -1268,6 +1271,7 @@ async fn frm_incoming_webhook_flow(
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentApprove,
|
||||
api::PaymentsCaptureRequest {
|
||||
@ -1293,6 +1297,7 @@ async fn frm_incoming_webhook_flow(
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.clone(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentReject,
|
||||
api::PaymentsCancelRequest {
|
||||
@ -1459,6 +1464,7 @@ async fn bank_transfer_webhook_flow(
|
||||
state.clone(),
|
||||
req_state,
|
||||
merchant_account.to_owned(),
|
||||
None,
|
||||
key_store.clone(),
|
||||
payments::PaymentConfirm,
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user