mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	fix(connector): Trigger Psync after redirection url (#2422)
This commit is contained in:
		| @ -878,8 +878,12 @@ impl services::ConnectorRedirectResponse for Authorizedotnet { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -692,9 +692,13 @@ impl services::ConnectorRedirectResponse for Bambora { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1095,31 +1095,36 @@ impl services::ConnectorRedirectResponse for Bluesnap { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         json_payload: Option<serde_json::Value>, |         json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload |         match action { | ||||||
|             .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload { |             services::PaymentAction::PSync => Ok(payments::CallConnectorAction::Trigger), | ||||||
|                 field_name: "json_payload", |             services::PaymentAction::CompleteAuthorize => { | ||||||
|             })? |                 let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload | ||||||
|             .parse_value("BluesnapRedirectionResponse") |                     .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload { | ||||||
|             .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; |                         field_name: "json_payload", | ||||||
|  |                     })? | ||||||
|  |                     .parse_value("BluesnapRedirectionResponse") | ||||||
|  |                     .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; | ||||||
|  |  | ||||||
|         let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response |                 let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response | ||||||
|             .authentication_response |                     .authentication_response | ||||||
|             .parse_struct("BluesnapThreeDsResult") |                     .parse_struct("BluesnapThreeDsResult") | ||||||
|             .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; |                     .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; | ||||||
|  |  | ||||||
|         match redirection_result.status.as_str() { |                 match redirection_result.status.as_str() { | ||||||
|             "Success" => Ok(payments::CallConnectorAction::Trigger), |                     "Success" => Ok(payments::CallConnectorAction::Trigger), | ||||||
|             _ => Ok(payments::CallConnectorAction::StatusUpdate { |                     _ => Ok(payments::CallConnectorAction::StatusUpdate { | ||||||
|                 status: enums::AttemptStatus::AuthenticationFailed, |                         status: enums::AttemptStatus::AuthenticationFailed, | ||||||
|                 error_code: redirection_result.code, |                         error_code: redirection_result.code, | ||||||
|                 error_message: redirection_result |                         error_message: redirection_result | ||||||
|                     .info |                             .info | ||||||
|                     .as_ref() |                             .as_ref() | ||||||
|                     .and_then(|info| info.errors.as_ref().and_then(|error| error.first())) |                             .and_then(|info| info.errors.as_ref().and_then(|error| error.first())) | ||||||
|                     .cloned(), |                             .cloned(), | ||||||
|             }), |                     }), | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1289,25 +1289,15 @@ impl api::IncomingWebhook for Checkout { | |||||||
| impl services::ConnectorRedirectResponse for Checkout { | impl services::ConnectorRedirectResponse for Checkout { | ||||||
|     fn get_flow_type( |     fn get_flow_type( | ||||||
|         &self, |         &self, | ||||||
|         query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         let query = |         match action { | ||||||
|             serde_urlencoded::from_str::<transformers::CheckoutRedirectResponse>(query_params) |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|                 .into_report() |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|                 .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) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -926,25 +926,14 @@ impl api::IncomingWebhook for Globalpay { | |||||||
| impl services::ConnectorRedirectResponse for Globalpay { | impl services::ConnectorRedirectResponse for Globalpay { | ||||||
|     fn get_flow_type( |     fn get_flow_type( | ||||||
|         &self, |         &self, | ||||||
|         query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<Value>, |         _json_payload: Option<Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         let query = serde_urlencoded::from_str::<response::GlobalpayRedirectResponse>(query_params) |         match action { | ||||||
|             .into_report() |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|             .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|         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, |  | ||||||
|             }, |  | ||||||
|         )) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -566,8 +566,12 @@ impl services::ConnectorRedirectResponse for Mollie { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -621,9 +621,13 @@ impl services::ConnectorRedirectResponse for Noon { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -340,9 +340,13 @@ impl services::ConnectorRedirectResponse for Payme { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1150,8 +1150,12 @@ impl services::ConnectorRedirectResponse for Paypal { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: PaymentAction, |         action: PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1962,33 +1962,14 @@ impl api::IncomingWebhook for Stripe { | |||||||
| impl services::ConnectorRedirectResponse for Stripe { | impl services::ConnectorRedirectResponse for Stripe { | ||||||
|     fn get_flow_type( |     fn get_flow_type( | ||||||
|         &self, |         &self, | ||||||
|         query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<crate::core::payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<crate::core::payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         let query = |         match action { | ||||||
|             serde_urlencoded::from_str::<transformers::StripeRedirectResponse>(query_params) |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|                 .into_report() |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|                 .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, |  | ||||||
|                     }, |  | ||||||
|                 }, |  | ||||||
|             )) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -956,26 +956,15 @@ impl api::IncomingWebhook for Trustpay { | |||||||
| impl services::ConnectorRedirectResponse for Trustpay { | impl services::ConnectorRedirectResponse for Trustpay { | ||||||
|     fn get_flow_type( |     fn get_flow_type( | ||||||
|         &self, |         &self, | ||||||
|         query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         let query = |         match action { | ||||||
|             serde_urlencoded::from_str::<transformers::TrustpayRedirectResponse>(query_params) |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|                 .into_report() |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|                 .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, |  | ||||||
|             }, |  | ||||||
|         )) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -683,8 +683,12 @@ impl services::ConnectorRedirectResponse for Zen { | |||||||
|         &self, |         &self, | ||||||
|         _query_params: &str, |         _query_params: &str, | ||||||
|         _json_payload: Option<serde_json::Value>, |         _json_payload: Option<serde_json::Value>, | ||||||
|         _action: services::PaymentAction, |         action: services::PaymentAction, | ||||||
|     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { |     ) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> { | ||||||
|         Ok(payments::CallConnectorAction::Trigger) |         match action { | ||||||
|  |             services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => { | ||||||
|  |                 Ok(payments::CallConnectorAction::Trigger) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1212,7 +1212,7 @@ pub fn build_redirection_form( | |||||||
|                 (PreEscaped(format!("<script> |                 (PreEscaped(format!("<script> | ||||||
|                     bluesnap.threeDsPaymentsSetup(\"{payment_fields_token}\", |                     bluesnap.threeDsPaymentsSetup(\"{payment_fields_token}\", | ||||||
|                     function(sdkResponse) {{ |                     function(sdkResponse) {{ | ||||||
|                         console.log(sdkResponse); |                         // console.log(sdkResponse); | ||||||
|                         var f = document.createElement('form'); |                         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.action=window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/bluesnap?paymentToken={payment_fields_token}\"); | ||||||
|                         f.method='POST'; |                         f.method='POST'; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 SamraatBansal
					SamraatBansal