mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(confirm): reduce the database calls to 2 stages in case of non-retry (#2113)
This commit is contained in:
		| @ -2772,7 +2772,7 @@ impl AttemptType { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub async fn get_connector_response( | ||||
|     pub async fn get_or_insert_connector_response( | ||||
|         &self, | ||||
|         payment_attempt: &PaymentAttempt, | ||||
|         db: &dyn StorageInterface, | ||||
| @ -2799,6 +2799,30 @@ impl AttemptType { | ||||
|                 .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub async fn get_connector_response( | ||||
|         &self, | ||||
|         db: &dyn StorageInterface, | ||||
|         payment_id: &str, | ||||
|         merchant_id: &str, | ||||
|         attempt_id: &str, | ||||
|         storage_scheme: storage_enums::MerchantStorageScheme, | ||||
|     ) -> RouterResult<storage::ConnectorResponse> { | ||||
|         match self { | ||||
|             Self::New => Err(errors::ApiErrorResponse::InternalServerError) | ||||
|                 .into_report() | ||||
|                 .attach_printable("Precondition failed, the attempt type should not be `New`"), | ||||
|             Self::SameOld => db | ||||
|                 .find_connector_response_by_payment_id_merchant_id_attempt_id( | ||||
|                     payment_id, | ||||
|                     merchant_id, | ||||
|                     attempt_id, | ||||
|                     storage_scheme, | ||||
|                 ) | ||||
|                 .await | ||||
|                 .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[inline(always)] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Nishant Joshi
					Nishant Joshi