1818using NLog ;
1919using AuthenticationSdk . util ;
2020using CyberSource . Utilities . Tracking ;
21+ using AuthenticationSdk . core ;
2122
2223namespace CyberSource . Api
2324{
@@ -372,7 +373,7 @@ public ApiResponse< PtsV2ModifyBillingAgreementPost201Response > BillingAgreemen
372373 {
373374 localVarPathParams . Add ( "id" , Configuration . ApiClient . ParameterToString ( id ) ) ; // path parameter
374375 }
375- // logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarPathParams)}");
376+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . ConvertDictionaryToString ( localVarPathParams ) } ") ;
376377 if ( modifyBillingAgreement != null && modifyBillingAgreement . GetType ( ) != typeof ( byte [ ] ) )
377378 {
378379 SdkTracker sdkTracker = new SdkTracker ( ) ;
@@ -384,14 +385,23 @@ public ApiResponse< PtsV2ModifyBillingAgreementPost201Response > BillingAgreemen
384385 localVarPostBody = modifyBillingAgreement ; // byte array
385386 }
386387
387- //if (logUtility.IsMaskingEnabled(logger))
388- //{
389- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
390- //}
391- //else
392- //{
393- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
394- //}
388+
389+ bool isMLESupportedByCybsForApi = true ;
390+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
391+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsDeRegistration,BillingAgreementsDeRegistrationAsync,BillingAgreementsDeRegistrationWithHttpInfo,BillingAgreementsDeRegistrationAsyncWithHttpInfo" ) )
392+ {
393+ try
394+ {
395+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
396+ }
397+ catch ( Exception e )
398+ {
399+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
400+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
401+ }
402+ }
403+
404+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
395405
396406
397407 // make the HTTP request
@@ -486,7 +496,7 @@ public async System.Threading.Tasks.Task<ApiResponse<PtsV2ModifyBillingAgreement
486496 {
487497 localVarPathParams . Add ( "id" , Configuration . ApiClient . ParameterToString ( id ) ) ; // path parameter
488498 }
489- // logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarPathParams)}");
499+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . ConvertDictionaryToString ( localVarPathParams ) } ") ;
490500 if ( modifyBillingAgreement != null && modifyBillingAgreement . GetType ( ) != typeof ( byte [ ] ) )
491501 {
492502 SdkTracker sdkTracker = new SdkTracker ( ) ;
@@ -498,14 +508,22 @@ public async System.Threading.Tasks.Task<ApiResponse<PtsV2ModifyBillingAgreement
498508 localVarPostBody = modifyBillingAgreement ; // byte array
499509 }
500510
501- //if (logUtility.IsMaskingEnabled(logger))
502- //{
503- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
504- //}
505- //else
506- //{
507- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
508- //}
511+ bool isMLESupportedByCybsForApi = true ;
512+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
513+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsDeRegistration,BillingAgreementsDeRegistrationAsync,BillingAgreementsDeRegistrationWithHttpInfo,BillingAgreementsDeRegistrationAsyncWithHttpInfo" ) )
514+ {
515+ try
516+ {
517+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
518+ }
519+ catch ( Exception e )
520+ {
521+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
522+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
523+ }
524+ }
525+
526+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
509527
510528
511529 // make the HTTP request
@@ -598,7 +616,7 @@ public ApiResponse< PtsV2CreditsPost201Response1 > BillingAgreementsIntimationWi
598616 {
599617 localVarPathParams . Add ( "id" , Configuration . ApiClient . ParameterToString ( id ) ) ; // path parameter
600618 }
601- // logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarPathParams)}");
619+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . ConvertDictionaryToString ( localVarPathParams ) } ") ;
602620 if ( intimateBillingAgreement != null && intimateBillingAgreement . GetType ( ) != typeof ( byte [ ] ) )
603621 {
604622 SdkTracker sdkTracker = new SdkTracker ( ) ;
@@ -610,14 +628,23 @@ public ApiResponse< PtsV2CreditsPost201Response1 > BillingAgreementsIntimationWi
610628 localVarPostBody = intimateBillingAgreement ; // byte array
611629 }
612630
613- //if (logUtility.IsMaskingEnabled(logger))
614- //{
615- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
616- //}
617- //else
618- //{
619- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
620- //}
631+
632+ bool isMLESupportedByCybsForApi = true ;
633+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
634+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsIntimation,BillingAgreementsIntimationAsync,BillingAgreementsIntimationWithHttpInfo,BillingAgreementsIntimationAsyncWithHttpInfo" ) )
635+ {
636+ try
637+ {
638+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
639+ }
640+ catch ( Exception e )
641+ {
642+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
643+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
644+ }
645+ }
646+
647+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
621648
622649
623650 // make the HTTP request
@@ -712,7 +739,7 @@ public async System.Threading.Tasks.Task<ApiResponse<PtsV2CreditsPost201Response
712739 {
713740 localVarPathParams . Add ( "id" , Configuration . ApiClient . ParameterToString ( id ) ) ; // path parameter
714741 }
715- // logger.Debug($"HTTP Request Body :\n{logUtility.ConvertDictionaryToString(localVarPathParams)}");
742+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . ConvertDictionaryToString ( localVarPathParams ) } ") ;
716743 if ( intimateBillingAgreement != null && intimateBillingAgreement . GetType ( ) != typeof ( byte [ ] ) )
717744 {
718745 SdkTracker sdkTracker = new SdkTracker ( ) ;
@@ -724,14 +751,22 @@ public async System.Threading.Tasks.Task<ApiResponse<PtsV2CreditsPost201Response
724751 localVarPostBody = intimateBillingAgreement ; // byte array
725752 }
726753
727- //if (logUtility.IsMaskingEnabled(logger))
728- //{
729- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
730- //}
731- //else
732- //{
733- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
734- //}
754+ bool isMLESupportedByCybsForApi = true ;
755+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
756+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsIntimation,BillingAgreementsIntimationAsync,BillingAgreementsIntimationWithHttpInfo,BillingAgreementsIntimationAsyncWithHttpInfo" ) )
757+ {
758+ try
759+ {
760+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
761+ }
762+ catch ( Exception e )
763+ {
764+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
765+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
766+ }
767+ }
768+
769+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
735770
736771
737772 // make the HTTP request
@@ -823,14 +858,23 @@ public ApiResponse< PtsV2CreateBillingAgreementPost201Response > BillingAgreemen
823858 localVarPostBody = createBillingAgreement ; // byte array
824859 }
825860
826- //if (logUtility.IsMaskingEnabled(logger))
827- //{
828- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
829- //}
830- //else
831- //{
832- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
833- //}
861+
862+ bool isMLESupportedByCybsForApi = true ;
863+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
864+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsRegistration,BillingAgreementsRegistrationAsync,BillingAgreementsRegistrationWithHttpInfo,BillingAgreementsRegistrationAsyncWithHttpInfo" ) )
865+ {
866+ try
867+ {
868+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
869+ }
870+ catch ( Exception e )
871+ {
872+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
873+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
874+ }
875+ }
876+
877+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
834878
835879
836880 // make the HTTP request
@@ -924,14 +968,22 @@ public async System.Threading.Tasks.Task<ApiResponse<PtsV2CreateBillingAgreement
924968 localVarPostBody = createBillingAgreement ; // byte array
925969 }
926970
927- //if (logUtility.IsMaskingEnabled(logger))
928- //{
929- // logger.Debug($"HTTP Request Body :\n{logUtility.MaskSensitiveData(localVarPostBody.ToString())}");
930- //}
931- //else
932- //{
933- // logger.Debug($"HTTP Request Body :\n{localVarPostBody}");
934- //}
971+ bool isMLESupportedByCybsForApi = true ;
972+ MerchantConfig merchantConfig = new MerchantConfig ( Configuration . MerchantConfigDictionaryObj , Configuration . MapToControlMLEonAPI ) ;
973+ if ( MLEUtility . CheckIsMLEForAPI ( merchantConfig , isMLESupportedByCybsForApi , "BillingAgreementsRegistration,BillingAgreementsRegistrationAsync,BillingAgreementsRegistrationWithHttpInfo,BillingAgreementsRegistrationAsyncWithHttpInfo" ) )
974+ {
975+ try
976+ {
977+ localVarPostBody = MLEUtility . EncryptRequestPayload ( merchantConfig , localVarPostBody ) ;
978+ }
979+ catch ( Exception e )
980+ {
981+ logger . Error ( "Failed to encrypt request body {}" , e . Message , e ) ;
982+ throw new ApiException ( 400 , "Failed to encrypt request body : " + e . Message ) ;
983+ }
984+ }
985+
986+ logger . Debug ( $ "HTTP Request Body :\n { logUtility . MaskSensitiveData ( localVarPostBody . ToString ( ) ) } ") ;
935987
936988
937989 // make the HTTP request
0 commit comments