Skip to content

Commit

Permalink
fix(connector): [Prophetpay] Use refund_id as reference_id for Refund (
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakilmostak authored Nov 23, 2023
1 parent 59ef162 commit dd3e22a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions crates/router/src/connector/prophetpay/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use url::Url;

use crate::{
connector::utils::{self, to_connector_meta},
consts as const_val,
core::errors,
services,
types::{self, api, storage::enums},
Expand Down Expand Up @@ -432,7 +433,6 @@ pub struct ProphetpaySyncResponse {
pub response_text: String,
#[serde(rename = "transactionID")]
pub transaction_id: String,
pub response_code: String,
}

impl<F, T>
Expand Down Expand Up @@ -462,7 +462,7 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::Failure,
response: Err(types::ErrorResponse {
code: item.response.response_code,
code: const_val::NO_ERROR_CODE.to_string(),
message: item.response.response_text.clone(),
reason: Some(item.response.response_text),
status_code: item.http_code,
Expand All @@ -481,7 +481,6 @@ pub struct ProphetpayVoidResponse {
pub response_text: String,
#[serde(rename = "transactionID")]
pub transaction_id: String,
pub response_code: String,
}

impl<F, T>
Expand Down Expand Up @@ -511,7 +510,7 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::VoidFailed,
response: Err(types::ErrorResponse {
code: item.response.response_code,
code: const_val::NO_ERROR_CODE.to_string(),
message: item.response.response_text.clone(),
reason: Some(item.response.response_text),
status_code: item.http_code,
Expand Down Expand Up @@ -576,8 +575,8 @@ impl<F> TryFrom<&ProphetpayRouterData<&types::RefundsRouterData<F>>> for Prophet
amount: item.amount.to_owned(),
card_token: card_token_data.card_token,
profile: auth_data.profile_id,
ref_info: item.router_data.connector_request_reference_id.to_owned(),
inquiry_reference: item.router_data.connector_request_reference_id.clone(),
ref_info: item.router_data.request.refund_id.to_owned(),
inquiry_reference: item.router_data.request.refund_id.clone(),
action_type: ProphetpayActionType::get_action_type(&ProphetpayActionType::Refund),
})
} else {
Expand All @@ -594,8 +593,7 @@ impl<F> TryFrom<&ProphetpayRouterData<&types::RefundsRouterData<F>>> for Prophet
pub struct ProphetpayRefundResponse {
pub success: bool,
pub response_text: String,
pub tran_seq_number: String,
pub response_code: String,
pub tran_seq_number: Option<String>,
}

impl TryFrom<types::RefundsResponseRouterData<api::Execute, ProphetpayRefundResponse>>
Expand All @@ -609,7 +607,11 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, ProphetpayRefundResp
Ok(Self {
response: Ok(types::RefundsResponseData {
// no refund id is generated, tranSeqNumber is kept for future usage
connector_refund_id: item.response.tran_seq_number,
connector_refund_id: item.response.tran_seq_number.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "tran_seq_number",
},
)?,
refund_status: enums::RefundStatus::Success,
}),
..item.data
Expand All @@ -618,7 +620,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, ProphetpayRefundResp
Ok(Self {
status: enums::AttemptStatus::Failure,
response: Err(types::ErrorResponse {
code: item.response.response_code,
code: const_val::NO_ERROR_CODE.to_string(),
message: item.response.response_text.clone(),
reason: Some(item.response.response_text),
status_code: item.http_code,
Expand All @@ -635,7 +637,6 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, ProphetpayRefundResp
pub struct ProphetpayRefundSyncResponse {
pub success: bool,
pub response_text: String,
pub response_code: String,
}

impl<T> TryFrom<types::RefundsResponseRouterData<T, ProphetpayRefundSyncResponse>>
Expand All @@ -658,7 +659,7 @@ impl<T> TryFrom<types::RefundsResponseRouterData<T, ProphetpayRefundSyncResponse
Ok(Self {
status: enums::AttemptStatus::Failure,
response: Err(types::ErrorResponse {
code: item.response.response_code,
code: const_val::NO_ERROR_CODE.to_string(),
message: item.response.response_text.clone(),
reason: Some(item.response.response_text),
status_code: item.http_code,
Expand Down

0 comments on commit dd3e22a

Please sign in to comment.