Skip to content

Commit 8029a89

Browse files
fix(connector): Trigger Psync after redirection url (#2422)
1 parent fc97ded commit 8029a89

File tree

13 files changed

+98
-116
lines changed

13 files changed

+98
-116
lines changed

crates/router/src/connector/authorizedotnet.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,12 @@ impl services::ConnectorRedirectResponse for Authorizedotnet {
878878
&self,
879879
_query_params: &str,
880880
_json_payload: Option<serde_json::Value>,
881-
_action: services::PaymentAction,
881+
action: services::PaymentAction,
882882
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
883-
Ok(payments::CallConnectorAction::Trigger)
883+
match action {
884+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
885+
Ok(payments::CallConnectorAction::Trigger)
886+
}
887+
}
884888
}
885889
}

crates/router/src/connector/bambora.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,13 @@ impl services::ConnectorRedirectResponse for Bambora {
692692
&self,
693693
_query_params: &str,
694694
_json_payload: Option<serde_json::Value>,
695-
_action: services::PaymentAction,
695+
action: services::PaymentAction,
696696
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
697-
Ok(payments::CallConnectorAction::Trigger)
697+
match action {
698+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
699+
Ok(payments::CallConnectorAction::Trigger)
700+
}
701+
}
698702
}
699703
}
700704

crates/router/src/connector/bluesnap.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,31 +1095,36 @@ impl services::ConnectorRedirectResponse for Bluesnap {
10951095
&self,
10961096
_query_params: &str,
10971097
json_payload: Option<serde_json::Value>,
1098-
_action: services::PaymentAction,
1098+
action: services::PaymentAction,
10991099
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
1100-
let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload
1101-
.ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
1102-
field_name: "json_payload",
1103-
})?
1104-
.parse_value("BluesnapRedirectionResponse")
1105-
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
1100+
match action {
1101+
services::PaymentAction::PSync => Ok(payments::CallConnectorAction::Trigger),
1102+
services::PaymentAction::CompleteAuthorize => {
1103+
let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload
1104+
.ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
1105+
field_name: "json_payload",
1106+
})?
1107+
.parse_value("BluesnapRedirectionResponse")
1108+
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
11061109

1107-
let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response
1108-
.authentication_response
1109-
.parse_struct("BluesnapThreeDsResult")
1110-
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
1110+
let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response
1111+
.authentication_response
1112+
.parse_struct("BluesnapThreeDsResult")
1113+
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
11111114

1112-
match redirection_result.status.as_str() {
1113-
"Success" => Ok(payments::CallConnectorAction::Trigger),
1114-
_ => Ok(payments::CallConnectorAction::StatusUpdate {
1115-
status: enums::AttemptStatus::AuthenticationFailed,
1116-
error_code: redirection_result.code,
1117-
error_message: redirection_result
1118-
.info
1119-
.as_ref()
1120-
.and_then(|info| info.errors.as_ref().and_then(|error| error.first()))
1121-
.cloned(),
1122-
}),
1115+
match redirection_result.status.as_str() {
1116+
"Success" => Ok(payments::CallConnectorAction::Trigger),
1117+
_ => Ok(payments::CallConnectorAction::StatusUpdate {
1118+
status: enums::AttemptStatus::AuthenticationFailed,
1119+
error_code: redirection_result.code,
1120+
error_message: redirection_result
1121+
.info
1122+
.as_ref()
1123+
.and_then(|info| info.errors.as_ref().and_then(|error| error.first()))
1124+
.cloned(),
1125+
}),
1126+
}
1127+
}
11231128
}
11241129
}
11251130
}

crates/router/src/connector/checkout.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,25 +1289,15 @@ impl api::IncomingWebhook for Checkout {
12891289
impl services::ConnectorRedirectResponse for Checkout {
12901290
fn get_flow_type(
12911291
&self,
1292-
query_params: &str,
1292+
_query_params: &str,
12931293
_json_payload: Option<serde_json::Value>,
1294-
_action: services::PaymentAction,
1294+
action: services::PaymentAction,
12951295
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
1296-
let query =
1297-
serde_urlencoded::from_str::<transformers::CheckoutRedirectResponse>(query_params)
1298-
.into_report()
1299-
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
1300-
let connector_action = query
1301-
.status
1302-
.map(
1303-
|checkout_status| payments::CallConnectorAction::StatusUpdate {
1304-
status: diesel_models::enums::AttemptStatus::from(checkout_status),
1305-
error_code: None,
1306-
error_message: None,
1307-
},
1308-
)
1309-
.unwrap_or(payments::CallConnectorAction::Trigger);
1310-
Ok(connector_action)
1296+
match action {
1297+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
1298+
Ok(payments::CallConnectorAction::Trigger)
1299+
}
1300+
}
13111301
}
13121302
}
13131303

crates/router/src/connector/globalpay.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -926,25 +926,14 @@ impl api::IncomingWebhook for Globalpay {
926926
impl services::ConnectorRedirectResponse for Globalpay {
927927
fn get_flow_type(
928928
&self,
929-
query_params: &str,
929+
_query_params: &str,
930930
_json_payload: Option<Value>,
931-
_action: services::PaymentAction,
931+
action: services::PaymentAction,
932932
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
933-
let query = serde_urlencoded::from_str::<response::GlobalpayRedirectResponse>(query_params)
934-
.into_report()
935-
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
936-
Ok(query.status.map_or(
937-
payments::CallConnectorAction::Trigger,
938-
|status| match status {
939-
response::GlobalpayPaymentStatus::Captured => {
940-
payments::CallConnectorAction::StatusUpdate {
941-
status: diesel_models::enums::AttemptStatus::from(status),
942-
error_code: None,
943-
error_message: None,
944-
}
945-
}
946-
_ => payments::CallConnectorAction::Trigger,
947-
},
948-
))
933+
match action {
934+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
935+
Ok(payments::CallConnectorAction::Trigger)
936+
}
937+
}
949938
}
950939
}

crates/router/src/connector/mollie.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,12 @@ impl services::ConnectorRedirectResponse for Mollie {
566566
&self,
567567
_query_params: &str,
568568
_json_payload: Option<serde_json::Value>,
569-
_action: services::PaymentAction,
569+
action: services::PaymentAction,
570570
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
571-
Ok(payments::CallConnectorAction::Trigger)
571+
match action {
572+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
573+
Ok(payments::CallConnectorAction::Trigger)
574+
}
575+
}
572576
}
573577
}

crates/router/src/connector/noon.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,13 @@ impl services::ConnectorRedirectResponse for Noon {
621621
&self,
622622
_query_params: &str,
623623
_json_payload: Option<serde_json::Value>,
624-
_action: services::PaymentAction,
624+
action: services::PaymentAction,
625625
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
626-
Ok(payments::CallConnectorAction::Trigger)
626+
match action {
627+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
628+
Ok(payments::CallConnectorAction::Trigger)
629+
}
630+
}
627631
}
628632
}
629633

crates/router/src/connector/payme.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,13 @@ impl services::ConnectorRedirectResponse for Payme {
340340
&self,
341341
_query_params: &str,
342342
_json_payload: Option<serde_json::Value>,
343-
_action: services::PaymentAction,
343+
action: services::PaymentAction,
344344
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
345-
Ok(payments::CallConnectorAction::Trigger)
345+
match action {
346+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
347+
Ok(payments::CallConnectorAction::Trigger)
348+
}
349+
}
346350
}
347351
}
348352

crates/router/src/connector/paypal.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,12 @@ impl services::ConnectorRedirectResponse for Paypal {
11501150
&self,
11511151
_query_params: &str,
11521152
_json_payload: Option<serde_json::Value>,
1153-
_action: PaymentAction,
1153+
action: PaymentAction,
11541154
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
1155-
Ok(payments::CallConnectorAction::Trigger)
1155+
match action {
1156+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
1157+
Ok(payments::CallConnectorAction::Trigger)
1158+
}
1159+
}
11561160
}
11571161
}

crates/router/src/connector/stripe.rs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,33 +1962,14 @@ impl api::IncomingWebhook for Stripe {
19621962
impl services::ConnectorRedirectResponse for Stripe {
19631963
fn get_flow_type(
19641964
&self,
1965-
query_params: &str,
1965+
_query_params: &str,
19661966
_json_payload: Option<serde_json::Value>,
1967-
_action: services::PaymentAction,
1967+
action: services::PaymentAction,
19681968
) -> CustomResult<crate::core::payments::CallConnectorAction, errors::ConnectorError> {
1969-
let query =
1970-
serde_urlencoded::from_str::<transformers::StripeRedirectResponse>(query_params)
1971-
.into_report()
1972-
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
1973-
1974-
crate::logger::debug!(stripe_redirect_response=?query);
1975-
1976-
Ok(query
1977-
.redirect_status
1978-
.map_or(
1979-
payments::CallConnectorAction::Trigger,
1980-
|status| match status {
1981-
transformers::StripePaymentStatus::Failed
1982-
| transformers::StripePaymentStatus::Pending
1983-
| transformers::StripePaymentStatus::Succeeded => {
1984-
payments::CallConnectorAction::Trigger
1985-
}
1986-
_ => payments::CallConnectorAction::StatusUpdate {
1987-
status: enums::AttemptStatus::from(status),
1988-
error_code: None,
1989-
error_message: None,
1990-
},
1991-
},
1992-
))
1969+
match action {
1970+
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
1971+
Ok(payments::CallConnectorAction::Trigger)
1972+
}
1973+
}
19931974
}
19941975
}

0 commit comments

Comments
 (0)