mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix: move connector_refund_id to request (#445)
This commit is contained in:
@ -467,16 +467,17 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for AuthorizedotnetCreateSyncReque
|
||||
|
||||
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
||||
let transaction_id = item
|
||||
.response
|
||||
.as_ref()
|
||||
.map(|refund_response_data| refund_response_data.connector_refund_id.clone())
|
||||
.ok();
|
||||
.request
|
||||
.connector_refund_id
|
||||
.clone()
|
||||
.get_required_value("connector_refund_id")
|
||||
.change_context(errors::ConnectorError::MissingConnectorRefundID)?;
|
||||
let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
|
||||
|
||||
let payload = Self {
|
||||
get_transaction_details_request: TransactionDetails {
|
||||
merchant_authentication,
|
||||
transaction_id,
|
||||
transaction_id: Some(transaction_id),
|
||||
},
|
||||
};
|
||||
Ok(payload)
|
||||
|
||||
@ -675,12 +675,11 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
|
||||
res: types::Response,
|
||||
) -> CustomResult<types::RefundsRouterData<api::RSync>, errors::ConnectorError> {
|
||||
let refund_action_id = data
|
||||
.response
|
||||
.request
|
||||
.connector_refund_id
|
||||
.clone()
|
||||
.ok()
|
||||
.get_required_value("response")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
|
||||
.connector_refund_id;
|
||||
.get_required_value("connector_refund_id")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
|
||||
let response: Vec<checkout::ActionResponse> = res
|
||||
.response
|
||||
|
||||
@ -445,12 +445,11 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
|
||||
connectors: &settings::Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
let refund_id = req
|
||||
.response
|
||||
.request
|
||||
.connector_refund_id
|
||||
.clone()
|
||||
.ok()
|
||||
.get_required_value("response")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
|
||||
.connector_refund_id;
|
||||
.get_required_value("connector_refund_id")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
Ok(format!(
|
||||
"{}refunds/{}",
|
||||
self.base_url(connectors),
|
||||
|
||||
@ -779,13 +779,11 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
|
||||
connectors: &settings::Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
let id = req
|
||||
.response
|
||||
.as_ref()
|
||||
.ok()
|
||||
.get_required_value("response")
|
||||
.change_context(errors::ConnectorError::FailedToObtainIntegrationUrl)?
|
||||
.request
|
||||
.connector_refund_id
|
||||
.clone();
|
||||
.clone()
|
||||
.get_required_value("connector_refund_id")
|
||||
.change_context(errors::ConnectorError::FailedToObtainIntegrationUrl)?;
|
||||
Ok(format!("{}v1/refunds/{}", self.base_url(connectors), id))
|
||||
}
|
||||
|
||||
|
||||
@ -601,13 +601,11 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
let refund_id = req
|
||||
.response
|
||||
.as_ref()
|
||||
.ok()
|
||||
.get_required_value("response")
|
||||
.change_context(errors::ConnectorError::FailedToObtainIntegrationUrl)?
|
||||
.request
|
||||
.connector_refund_id
|
||||
.clone();
|
||||
.clone()
|
||||
.get_required_value("connector_refund_id")
|
||||
.change_context(errors::ConnectorError::FailedToObtainIntegrationUrl)?;
|
||||
let base_url = self.base_url(connectors);
|
||||
let auth: worldline::AuthType = worldline::AuthType::try_from(&req.connector_auth_type)?;
|
||||
let merchant_account_id = auth.merchant_account_id;
|
||||
|
||||
@ -237,6 +237,8 @@ pub enum ConnectorError {
|
||||
NotImplemented(String),
|
||||
#[error("Missing connector transaction ID")]
|
||||
MissingConnectorTransactionID,
|
||||
#[error("Missing connector refund ID")]
|
||||
MissingConnectorRefundID,
|
||||
#[error("Webhooks not implemented for this connector")]
|
||||
WebhooksNotImplemented,
|
||||
#[error("Failed to decode webhook event body")]
|
||||
|
||||
@ -295,10 +295,12 @@ pub async fn sync_refund_with_gateway(
|
||||
|
||||
logger::debug!(refund_retrieve_router_data=?router_data);
|
||||
|
||||
if add_access_token_result.connector_supports_access_token {
|
||||
match add_access_token_result.access_token_result {
|
||||
Ok(access_token) => router_data.access_token = access_token,
|
||||
Err(connector_error) => router_data.response = Err(connector_error),
|
||||
}
|
||||
}
|
||||
|
||||
let router_data_res = if !(add_access_token_result.connector_supports_access_token
|
||||
&& router_data.access_token.is_none())
|
||||
|
||||
@ -74,6 +74,7 @@ pub async fn construct_refund_router_data<'a, F>(
|
||||
amount,
|
||||
connector_metadata: payment_attempt.connector_metadata.clone(),
|
||||
reason: refund.refund_reason.clone(),
|
||||
connector_refund_id: refund.connector_refund_id.clone(),
|
||||
},
|
||||
|
||||
response: Ok(types::RefundsResponseData {
|
||||
|
||||
@ -217,6 +217,8 @@ impl ResponseId {
|
||||
pub struct RefundsData {
|
||||
pub refund_id: String,
|
||||
pub connector_transaction_id: String,
|
||||
|
||||
pub connector_refund_id: Option<String>,
|
||||
pub currency: storage_enums::Currency,
|
||||
/// Amount for the payment against which this refund is issued
|
||||
pub amount: i64,
|
||||
|
||||
@ -87,6 +87,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
|
||||
refund_amount: 100,
|
||||
connector_metadata: None,
|
||||
reason: None,
|
||||
connector_refund_id: None,
|
||||
},
|
||||
payment_method_id: None,
|
||||
response: Err(types::ErrorResponse::default()),
|
||||
|
||||
@ -87,6 +87,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
|
||||
refund_amount: 1,
|
||||
connector_metadata: None,
|
||||
reason: None,
|
||||
connector_refund_id: None,
|
||||
},
|
||||
response: Err(types::ErrorResponse::default()),
|
||||
payment_method_id: None,
|
||||
|
||||
@ -84,6 +84,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
|
||||
refund_amount: 10,
|
||||
connector_metadata: None,
|
||||
reason: None,
|
||||
connector_refund_id: None,
|
||||
},
|
||||
response: Err(types::ErrorResponse::default()),
|
||||
payment_method_id: None,
|
||||
|
||||
@ -144,6 +144,7 @@ pub trait ConnectorActions: Connector {
|
||||
connector_transaction_id: transaction_id,
|
||||
refund_amount: 100,
|
||||
connector_metadata: None,
|
||||
connector_refund_id: None,
|
||||
reason: Some("Customer returned product".to_string()),
|
||||
}),
|
||||
payment_info,
|
||||
@ -167,6 +168,7 @@ pub trait ConnectorActions: Connector {
|
||||
refund_amount: 100,
|
||||
connector_metadata: None,
|
||||
reason: None,
|
||||
connector_refund_id: None,
|
||||
}),
|
||||
payment_info,
|
||||
);
|
||||
@ -335,6 +337,7 @@ impl Default for PaymentRefundType {
|
||||
refund_amount: 100,
|
||||
connector_metadata: None,
|
||||
reason: None,
|
||||
connector_refund_id: None,
|
||||
};
|
||||
Self(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user