mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 05:59:48 +08:00 
			
		
		
		
	fix: Update browser info on payment confirmation (#52)
This commit is contained in:
		@ -18,11 +18,11 @@ use crate::{
 | 
			
		||||
    },
 | 
			
		||||
    routes::AppState,
 | 
			
		||||
    types::{
 | 
			
		||||
        api,
 | 
			
		||||
        self, api,
 | 
			
		||||
        storage::{self, enums},
 | 
			
		||||
        Connector,
 | 
			
		||||
    },
 | 
			
		||||
    utils::OptionExt,
 | 
			
		||||
    utils::{self, OptionExt},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Clone, Copy, PaymentOperation)]
 | 
			
		||||
@ -71,6 +71,15 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let browser_info = request
 | 
			
		||||
            .browser_info
 | 
			
		||||
            .clone()
 | 
			
		||||
            .map(|x| utils::Encode::<types::BrowserInformation>::encode_to_value(&x))
 | 
			
		||||
            .transpose()
 | 
			
		||||
            .change_context(errors::ApiErrorResponse::InvalidDataValue {
 | 
			
		||||
                field_name: "browser_info",
 | 
			
		||||
            })?;
 | 
			
		||||
 | 
			
		||||
        payment_attempt = db
 | 
			
		||||
            .find_payment_attempt_by_payment_id_merchant_id(&payment_id, merchant_id)
 | 
			
		||||
            .await
 | 
			
		||||
@ -80,6 +89,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
 | 
			
		||||
        payment_attempt.payment_method = payment_method_type.or(payment_attempt.payment_method);
 | 
			
		||||
 | 
			
		||||
        payment_attempt.payment_method = payment_method_type.or(payment_attempt.payment_method);
 | 
			
		||||
        payment_attempt.browser_info = browser_info;
 | 
			
		||||
        currency = payment_attempt.currency.get_required_value("currency")?;
 | 
			
		||||
        amount = payment_attempt.amount;
 | 
			
		||||
 | 
			
		||||
@ -163,6 +173,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
 | 
			
		||||
        F: 'b + Send,
 | 
			
		||||
    {
 | 
			
		||||
        let payment_method = payment_data.payment_attempt.payment_method;
 | 
			
		||||
        let browser_info = payment_data.payment_attempt.browser_info.clone();
 | 
			
		||||
 | 
			
		||||
        let (intent_status, attempt_status) = match payment_data.payment_attempt.authentication_type
 | 
			
		||||
        {
 | 
			
		||||
@ -182,6 +193,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
 | 
			
		||||
                storage::PaymentAttemptUpdate::ConfirmUpdate {
 | 
			
		||||
                    status: attempt_status,
 | 
			
		||||
                    payment_method,
 | 
			
		||||
                    browser_info,
 | 
			
		||||
                },
 | 
			
		||||
            )
 | 
			
		||||
            .await
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user