mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	fix(connector): [Cybersource] Throw proper unauthorised message (#1529)
Co-authored-by: Abhishek Marrivagu <68317979+Abhicodes-crypto@users.noreply.github.com>
This commit is contained in:
		| @ -104,6 +104,13 @@ impl ConnectorCommon for Cybersource { | |||||||
|             .map(|det| format!("{} : {}", det.field, det.reason)) |             .map(|det| format!("{} : {}", det.field, det.reason)) | ||||||
|             .collect::<Vec<_>>() |             .collect::<Vec<_>>() | ||||||
|             .join(", "); |             .join(", "); | ||||||
|  |  | ||||||
|  |         let error_message = if res.status_code == 401 { | ||||||
|  |             consts::CONNECTOR_UNAUTHORIZED_ERROR | ||||||
|  |         } else { | ||||||
|  |             consts::NO_ERROR_MESSAGE | ||||||
|  |         }; | ||||||
|  |  | ||||||
|         let (code, message) = match response.error_information { |         let (code, message) = match response.error_information { | ||||||
|             Some(ref error_info) => (error_info.reason.clone(), error_info.message.clone()), |             Some(ref error_info) => (error_info.reason.clone(), error_info.message.clone()), | ||||||
|             None => ( |             None => ( | ||||||
| @ -114,7 +121,7 @@ impl ConnectorCommon for Cybersource { | |||||||
|                     }), |                     }), | ||||||
|                 response |                 response | ||||||
|                     .message |                     .message | ||||||
|                     .map_or(consts::NO_ERROR_MESSAGE.to_string(), |message| message), |                     .map_or(error_message.to_string(), |message| message), | ||||||
|             ), |             ), | ||||||
|         }; |         }; | ||||||
|         Ok(types::ErrorResponse { |         Ok(types::ErrorResponse { | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ pub const DEFAULT_FULFILLMENT_TIME: i64 = 15 * 60; | |||||||
| // String literals | // String literals | ||||||
| pub(crate) const NO_ERROR_MESSAGE: &str = "No error message"; | pub(crate) const NO_ERROR_MESSAGE: &str = "No error message"; | ||||||
| pub(crate) const NO_ERROR_CODE: &str = "No error code"; | pub(crate) const NO_ERROR_CODE: &str = "No error code"; | ||||||
|  | pub(crate) const CONNECTOR_UNAUTHORIZED_ERROR: &str = "Authentication Error from the connector"; | ||||||
|  |  | ||||||
| // General purpose base64 engines | // General purpose base64 engines | ||||||
| pub(crate) const BASE64_ENGINE: base64::engine::GeneralPurpose = | pub(crate) const BASE64_ENGINE: base64::engine::GeneralPurpose = | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Kartikeya Hegde
					Kartikeya Hegde