@@ -2,7 +2,7 @@ use std::{fmt::Debug, marker::PhantomData, str::FromStr};
2
2
3
3
use api_models:: payments:: {
4
4
Address , ConnectorMandateReferenceId , CustomerDetails , CustomerDetailsResponse , FrmMessage ,
5
- RequestSurchargeDetails ,
5
+ MandateIds , RequestSurchargeDetails ,
6
6
} ;
7
7
use common_enums:: { Currency , RequestIncrementalAuthorization } ;
8
8
use common_utils:: {
@@ -3366,6 +3366,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
3366
3366
}
3367
3367
}
3368
3368
3369
+ fn get_off_session (
3370
+ mandate_id : Option < & MandateIds > ,
3371
+ off_session_flag : Option < bool > ,
3372
+ ) -> Option < bool > {
3373
+ match ( mandate_id, off_session_flag) {
3374
+ ( _, Some ( false ) ) => Some ( false ) ,
3375
+ ( Some ( _) , _) | ( _, Some ( true ) ) => Some ( true ) ,
3376
+ ( None , None ) => None ,
3377
+ }
3378
+ }
3379
+
3369
3380
#[ cfg( all( any( feature = "v1" , feature = "v2" ) , not( feature = "customer_v2" ) ) ) ]
3370
3381
impl < F : Clone > TryFrom < PaymentAdditionalData < ' _ , F > > for types:: PaymentsAuthorizeData {
3371
3382
type Error = error_stack:: Report < errors:: ApiErrorResponse > ;
@@ -3520,12 +3531,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
3520
3531
} )
3521
3532
. transpose ( ) ?
3522
3533
. map ( pii:: SecretSerdeValue :: new) ;
3534
+ let is_off_session = get_off_session (
3535
+ payment_data. mandate_id . as_ref ( ) ,
3536
+ payment_data. payment_intent . off_session ,
3537
+ ) ;
3523
3538
3524
3539
Ok ( Self {
3525
3540
payment_method_data : ( payment_method_data. get_required_value ( "payment_method_data" ) ?) ,
3526
3541
setup_future_usage : payment_data. payment_attempt . setup_future_usage_applied ,
3527
3542
mandate_id : payment_data. mandate_id . clone ( ) ,
3528
- off_session : payment_data . mandate_id . as_ref ( ) . map ( |_| true ) ,
3543
+ off_session : is_off_session ,
3529
3544
setup_mandate_details : payment_data. setup_mandate . clone ( ) ,
3530
3545
confirm : payment_data. payment_attempt . confirm ,
3531
3546
statement_descriptor_suffix : payment_data. payment_intent . statement_descriptor_suffix ,
@@ -4361,6 +4376,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
4361
4376
. transpose ( ) ?
4362
4377
. map ( pii:: SecretSerdeValue :: new) ;
4363
4378
4379
+ let is_off_session = get_off_session (
4380
+ payment_data. mandate_id . as_ref ( ) ,
4381
+ payment_data. payment_intent . off_session ,
4382
+ ) ;
4383
+
4364
4384
Ok ( Self {
4365
4385
currency : payment_data. currency ,
4366
4386
confirm : true ,
@@ -4371,7 +4391,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
4371
4391
. get_required_value ( "payment_method_data" ) ?) ,
4372
4392
statement_descriptor_suffix : payment_data. payment_intent . statement_descriptor_suffix ,
4373
4393
setup_future_usage : payment_data. payment_attempt . setup_future_usage_applied ,
4374
- off_session : payment_data . mandate_id . as_ref ( ) . map ( |_| true ) ,
4394
+ off_session : is_off_session ,
4375
4395
mandate_id : payment_data. mandate_id . clone ( ) ,
4376
4396
setup_mandate_details : payment_data. setup_mandate ,
4377
4397
customer_acceptance : payment_data. customer_acceptance ,
@@ -4505,10 +4525,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
4505
4525
. and_then ( |braintree| braintree. merchant_account_id . clone ( ) ) ;
4506
4526
let merchant_config_currency =
4507
4527
braintree_metadata. and_then ( |braintree| braintree. merchant_config_currency ) ;
4528
+
4529
+ let is_off_session = get_off_session (
4530
+ payment_data. mandate_id . as_ref ( ) ,
4531
+ payment_data. payment_intent . off_session ,
4532
+ ) ;
4533
+
4508
4534
Ok ( Self {
4509
4535
setup_future_usage : payment_data. payment_intent . setup_future_usage ,
4510
4536
mandate_id : payment_data. mandate_id . clone ( ) ,
4511
- off_session : payment_data . mandate_id . as_ref ( ) . map ( |_| true ) ,
4537
+ off_session : is_off_session ,
4512
4538
setup_mandate_details : payment_data. setup_mandate . clone ( ) ,
4513
4539
confirm : payment_data. payment_attempt . confirm ,
4514
4540
statement_descriptor_suffix : payment_data. payment_intent . statement_descriptor_suffix ,
0 commit comments