mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(connector): [Noon] add error response handling in payments response (#1494)
This commit is contained in:
		| @ -7,7 +7,7 @@ use crate::{ | |||||||
|     }, |     }, | ||||||
|     core::errors, |     core::errors, | ||||||
|     services, |     services, | ||||||
|     types::{self, api, storage::enums}, |     types::{self, api, storage::enums, ErrorResponse}, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // These needs to be accepted from SDK, need to be done after 1.0.0 stability as API contract will change | // These needs to be accepted from SDK, need to be done after 1.0.0 stability as API contract will change | ||||||
| @ -280,6 +280,8 @@ pub struct NoonSubscriptionResponse { | |||||||
| pub struct NoonPaymentsOrderResponse { | pub struct NoonPaymentsOrderResponse { | ||||||
|     status: NoonPaymentStatus, |     status: NoonPaymentStatus, | ||||||
|     id: u64, |     id: u64, | ||||||
|  |     error_code: u64, | ||||||
|  |     error_message: Option<String>, | ||||||
| } | } | ||||||
|  |  | ||||||
| #[derive(Debug, Deserialize)] | #[derive(Debug, Deserialize)] | ||||||
| @ -324,17 +326,24 @@ impl<F, T> | |||||||
|                     connector_mandate_id: Some(subscription_data.identifier), |                     connector_mandate_id: Some(subscription_data.identifier), | ||||||
|                     payment_method_id: None, |                     payment_method_id: None, | ||||||
|                 }); |                 }); | ||||||
|  |         let order = item.response.result.order; | ||||||
|         Ok(Self { |         Ok(Self { | ||||||
|             status: enums::AttemptStatus::from(item.response.result.order.status), |             status: enums::AttemptStatus::from(order.status), | ||||||
|             response: Ok(types::PaymentsResponseData::TransactionResponse { |             response: match order.error_message { | ||||||
|                 resource_id: types::ResponseId::ConnectorTransactionId( |                 Some(error_message) => Err(ErrorResponse { | ||||||
|                     item.response.result.order.id.to_string(), |                     code: order.error_code.to_string(), | ||||||
|                 ), |                     message: error_message.clone(), | ||||||
|                 redirection_data, |                     reason: Some(error_message), | ||||||
|                 mandate_reference, |                     status_code: item.http_code, | ||||||
|                 connector_metadata: None, |                 }), | ||||||
|                 network_txn_id: None, |                 _ => Ok(types::PaymentsResponseData::TransactionResponse { | ||||||
|             }), |                     resource_id: types::ResponseId::ConnectorTransactionId(order.id.to_string()), | ||||||
|  |                     redirection_data, | ||||||
|  |                     mandate_reference, | ||||||
|  |                     connector_metadata: None, | ||||||
|  |                     network_txn_id: None, | ||||||
|  |                 }), | ||||||
|  |             }, | ||||||
|             ..item.data |             ..item.data | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 SamraatBansal
					SamraatBansal