Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): Trigger Psync after redirection url (#2422)
SamraatBansal8029a895b2c2
diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rsindex 8e98fc5843..99e87ca1ed 100644--- a/crates/router/src/connector/authorizedotnet.rs+++ b/crates/router/src/connector/authorizedotnet.rs@@ -878,8 +878,12 @@ impl services::ConnectorRedirectResponse for Authorizedotnet {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rsindex b59645a409..d5e8119b66 100644--- a/crates/router/src/connector/bambora.rs+++ b/crates/router/src/connector/bambora.rs@@ -692,9 +692,13 @@ impl services::ConnectorRedirectResponse for Bambora {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rsindex 7a867ed56c..24d5787aa8 100644--- a/crates/router/src/connector/bluesnap.rs+++ b/crates/router/src/connector/bluesnap.rs@@ -1095,31 +1095,36 @@ impl services::ConnectorRedirectResponse for Bluesnap {&self,_query_params: &str,json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload- .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {- field_name: "json_payload",- })?- .parse_value("BluesnapRedirectionResponse")- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ match action {+ services::PaymentAction::PSync => Ok(payments::CallConnectorAction::Trigger),+ services::PaymentAction::CompleteAuthorize => {+ let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload+ .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {+ field_name: "json_payload",+ })?+ .parse_value("BluesnapRedirectionResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response- .authentication_response- .parse_struct("BluesnapThreeDsResult")- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response+ .authentication_response+ .parse_struct("BluesnapThreeDsResult")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- match redirection_result.status.as_str() {- "Success" => Ok(payments::CallConnectorAction::Trigger),- _ => Ok(payments::CallConnectorAction::StatusUpdate {- status: enums::AttemptStatus::AuthenticationFailed,- error_code: redirection_result.code,- error_message: redirection_result- .info- .as_ref()- .and_then(|info| info.errors.as_ref().and_then(|error| error.first()))- .cloned(),- }),+ match redirection_result.status.as_str() {+ "Success" => Ok(payments::CallConnectorAction::Trigger),+ _ => Ok(payments::CallConnectorAction::StatusUpdate {+ status: enums::AttemptStatus::AuthenticationFailed,+ error_code: redirection_result.code,+ error_message: redirection_result+ .info+ .as_ref()+ .and_then(|info| info.errors.as_ref().and_then(|error| error.first()))+ .cloned(),+ }),+ }+ }}}}diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rsindex 52c4351287..f4cc4ac964 100644--- a/crates/router/src/connector/checkout.rs+++ b/crates/router/src/connector/checkout.rs@@ -1289,25 +1289,15 @@ impl api::IncomingWebhook for Checkout {impl services::ConnectorRedirectResponse for Checkout {fn get_flow_type(&self,- query_params: &str,+ _query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- let query =- serde_urlencoded::from_str::<transformers::CheckoutRedirectResponse>(query_params)- .into_report()- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- let connector_action = query- .status- .map(- |checkout_status| payments::CallConnectorAction::StatusUpdate {- status: diesel_models::enums::AttemptStatus::from(checkout_status),- error_code: None,- error_message: None,- },- )- .unwrap_or(payments::CallConnectorAction::Trigger);- Ok(connector_action)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rsindex 5b545c0d01..dfcddae777 100644--- a/crates/router/src/connector/globalpay.rs+++ b/crates/router/src/connector/globalpay.rs@@ -926,25 +926,14 @@ impl api::IncomingWebhook for Globalpay {impl services::ConnectorRedirectResponse for Globalpay {fn get_flow_type(&self,- query_params: &str,+ _query_params: &str,_json_payload: Option<Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- let query = serde_urlencoded::from_str::<response::GlobalpayRedirectResponse>(query_params)- .into_report()- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- Ok(query.status.map_or(- payments::CallConnectorAction::Trigger,- |status| match status {- response::GlobalpayPaymentStatus::Captured => {- payments::CallConnectorAction::StatusUpdate {- status: diesel_models::enums::AttemptStatus::from(status),- error_code: None,- error_message: None,- }- }- _ => payments::CallConnectorAction::Trigger,- },- ))+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/mollie.rs b/crates/router/src/connector/mollie.rsindex d0b2b635fc..38abed9dea 100644--- a/crates/router/src/connector/mollie.rs+++ b/crates/router/src/connector/mollie.rs@@ -566,8 +566,12 @@ impl services::ConnectorRedirectResponse for Mollie {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rsindex 771c444a43..a8800ebcbe 100644--- a/crates/router/src/connector/noon.rs+++ b/crates/router/src/connector/noon.rs@@ -621,9 +621,13 @@ impl services::ConnectorRedirectResponse for Noon {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rsindex 92a19d4296..e0d6229c00 100644--- a/crates/router/src/connector/payme.rs+++ b/crates/router/src/connector/payme.rs@@ -340,9 +340,13 @@ impl services::ConnectorRedirectResponse for Payme {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rsindex 1faee2a16b..1f872868a0 100644--- a/crates/router/src/connector/paypal.rs+++ b/crates/router/src/connector/paypal.rs@@ -1150,8 +1150,12 @@ impl services::ConnectorRedirectResponse for Paypal {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: PaymentAction,+ action: PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rsindex 734dca3016..ff89882543 100644--- a/crates/router/src/connector/stripe.rs+++ b/crates/router/src/connector/stripe.rs@@ -1962,33 +1962,14 @@ impl api::IncomingWebhook for Stripe {impl services::ConnectorRedirectResponse for Stripe {fn get_flow_type(&self,- query_params: &str,+ _query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<crate::core::payments::CallConnectorAction, errors::ConnectorError> {- let query =- serde_urlencoded::from_str::<transformers::StripeRedirectResponse>(query_params)- .into_report()- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;-- crate::logger::debug!(stripe_redirect_response=?query);-- Ok(query- .redirect_status- .map_or(- payments::CallConnectorAction::Trigger,- |status| match status {- transformers::StripePaymentStatus::Failed- | transformers::StripePaymentStatus::Pending- | transformers::StripePaymentStatus::Succeeded => {- payments::CallConnectorAction::Trigger- }- _ => payments::CallConnectorAction::StatusUpdate {- status: enums::AttemptStatus::from(status),- error_code: None,- error_message: None,- },- },- ))+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rsindex f182b44497..b631a9611c 100644--- a/crates/router/src/connector/trustpay.rs+++ b/crates/router/src/connector/trustpay.rs@@ -956,26 +956,15 @@ impl api::IncomingWebhook for Trustpay {impl services::ConnectorRedirectResponse for Trustpay {fn get_flow_type(&self,- query_params: &str,+ _query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- let query =- serde_urlencoded::from_str::<transformers::TrustpayRedirectResponse>(query_params)- .into_report()- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- crate::logger::debug!(trustpay_redirect_response=?query);- Ok(query.status.map_or(- payments::CallConnectorAction::Trigger,- |status| match status.as_str() {- "SuccessOk" => payments::CallConnectorAction::StatusUpdate {- status: diesel_models::enums::AttemptStatus::Charged,- error_code: None,- error_message: None,- },- _ => payments::CallConnectorAction::Trigger,- },- ))+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rsindex f65cb02b94..d93075c373 100644--- a/crates/router/src/connector/zen.rs+++ b/crates/router/src/connector/zen.rs@@ -683,8 +683,12 @@ impl services::ConnectorRedirectResponse for Zen {&self,_query_params: &str,_json_payload: Option<serde_json::Value>,- _action: services::PaymentAction,+ action: services::PaymentAction,) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {- Ok(payments::CallConnectorAction::Trigger)+ match action {+ services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {+ Ok(payments::CallConnectorAction::Trigger)+ }+ }}}diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex 8506e26f58..6fe4c01cc2 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -1212,7 +1212,7 @@ pub fn build_redirection_form((PreEscaped(format!("<script>bluesnap.threeDsPaymentsSetup(\"{payment_fields_token}\",function(sdkResponse) {{- console.log(sdkResponse);+ // console.log(sdkResponse);var f = document.createElement('form');f.action=window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/bluesnap?paymentToken={payment_fields_token}\");f.method='POST';