mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(router): add adyen split payments support (#6952)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -461,6 +461,86 @@ pub fn validate_uuid(uuid: String, key: &str) -> Result<String, errors::ApiError | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "v1")] | ||||
| pub fn get_split_refunds( | ||||
|     split_refund_input: super::refunds::transformers::SplitRefundInput, | ||||
| ) -> RouterResult<Option<router_request_types::SplitRefundsRequest>> { | ||||
|     match split_refund_input.split_payment_request.as_ref() { | ||||
|         Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment(stripe_payment)) => { | ||||
|             let (charge_id_option, charge_type_option) = match ( | ||||
|                 &split_refund_input.payment_charges, | ||||
|                 &split_refund_input.split_payment_request, | ||||
|             ) { | ||||
|                 ( | ||||
|                     Some(common_types::payments::ConnectorChargeResponseData::StripeSplitPayment( | ||||
|                         stripe_split_payment_response, | ||||
|                     )), | ||||
|                     _, | ||||
|                 ) => ( | ||||
|                     stripe_split_payment_response.charge_id.clone(), | ||||
|                     Some(stripe_split_payment_response.charge_type.clone()), | ||||
|                 ), | ||||
|                 ( | ||||
|                     _, | ||||
|                     Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( | ||||
|                         stripe_split_payment_request, | ||||
|                     )), | ||||
|                 ) => ( | ||||
|                     split_refund_input.charge_id, | ||||
|                     Some(stripe_split_payment_request.charge_type.clone()), | ||||
|                 ), | ||||
|                 (_, _) => (None, None), | ||||
|             }; | ||||
|  | ||||
|             if let Some(charge_id) = charge_id_option { | ||||
|                 let options = super::refunds::validator::validate_stripe_charge_refund( | ||||
|                     charge_type_option, | ||||
|                     &split_refund_input.refund_request, | ||||
|                 )?; | ||||
|  | ||||
|                 Ok(Some( | ||||
|                     router_request_types::SplitRefundsRequest::StripeSplitRefund( | ||||
|                         router_request_types::StripeSplitRefund { | ||||
|                             charge_id, | ||||
|                             charge_type: stripe_payment.charge_type.clone(), | ||||
|                             transfer_account_id: stripe_payment.transfer_account_id.clone(), | ||||
|                             options, | ||||
|                         }, | ||||
|                     ), | ||||
|                 )) | ||||
|             } else { | ||||
|                 Ok(None) | ||||
|             } | ||||
|         } | ||||
|         Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(_)) => { | ||||
|             match &split_refund_input.payment_charges { | ||||
|                 Some(common_types::payments::ConnectorChargeResponseData::AdyenSplitPayment( | ||||
|                     adyen_split_payment_response, | ||||
|                 )) => { | ||||
|                     if let Some(common_types::refunds::SplitRefund::AdyenSplitRefund( | ||||
|                         split_refund_request, | ||||
|                     )) = split_refund_input.refund_request.clone() | ||||
|                     { | ||||
|                         super::refunds::validator::validate_adyen_charge_refund( | ||||
|                             adyen_split_payment_response, | ||||
|                             &split_refund_request, | ||||
|                         )?; | ||||
|  | ||||
|                         Ok(Some( | ||||
|                             router_request_types::SplitRefundsRequest::AdyenSplitRefund( | ||||
|                                 split_refund_request, | ||||
|                             ), | ||||
|                         )) | ||||
|                     } else { | ||||
|                         Ok(None) | ||||
|                     } | ||||
|                 } | ||||
|                 _ => Ok(None), | ||||
|             } | ||||
|         } | ||||
|         _ => Ok(None), | ||||
|     } | ||||
| } | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     #![allow(clippy::expect_used)] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 AkshayaFoiger
					AkshayaFoiger