@@ -480,22 +480,29 @@ public async Task<RedeemVoucherResponse> RedeemVoucher(Guid estateId,
480480 public async Task < Result < List < Models . ContractResponse > > > GetMerchantContracts ( Guid estateId ,
481481 Guid merchantId ,
482482 CancellationToken cancellationToken ) {
483+ Logger . LogInformation ( $ "GetMerchantContracts: { estateId } { merchantId } ") ;
483484 // Get a client token to call the Transaction Processor
484485 String clientId = ConfigurationReader . GetValue ( "AppSettings" , "ClientId" ) ;
485486 String clientSecret = ConfigurationReader . GetValue ( "AppSettings" , "ClientSecret" ) ;
486487
487488 TokenResponse accessToken = await this . SecurityServiceClient . GetToken ( clientId , clientSecret , cancellationToken ) ;
488-
489- ProcessLogonTransactionResponse response = null ;
489+ if ( accessToken == null ) {
490+ Logger . LogInformation ( $ "token is null") ;
491+ return Result . Failure ( "Error getting access token" ) ;
492+ }
493+ Logger . LogInformation ( $ "{ JsonConvert . SerializeObject ( accessToken ) } ") ;
490494
491495 Result < List < TransactionProcessor . DataTransferObjects . Responses . Contract . ContractResponse > > result = await this . TransactionProcessorClient . GetMerchantContracts ( accessToken . AccessToken , estateId , merchantId , cancellationToken ) ;
492496
493497 if ( result . IsFailed )
494498 return Result . Failure ( $ "Error getting merchant contracts { result . Message } ") ;
495499
500+ Logger . LogInformation ( $ "Got the merchant contracts { result . Data . Count } ") ;
496501 List < Models . ContractResponse > models = new ( ) ;
497502
498503 foreach ( TransactionProcessor . DataTransferObjects . Responses . Contract . ContractResponse contractResponse in result . Data ) {
504+ Logger . LogInformation ( $ "Processing contract { contractResponse . OperatorName } ") ;
505+
499506 ContractResponse contractModel = new ContractResponse {
500507 ContractId = contractResponse . ContractId ,
501508 ContractReportingId = contractResponse . ContractReportingId ,
@@ -508,6 +515,7 @@ public async Task<RedeemVoucherResponse> RedeemVoucher(Guid estateId,
508515 } ;
509516
510517 foreach ( TransactionProcessor . DataTransferObjects . Responses . Contract . ContractProduct contractResponseProduct in contractResponse . Products ) {
518+ Logger . LogInformation ( $ "Processing contract product { contractResponseProduct . DisplayText } ") ;
511519 ContractProduct productModel = new ContractProduct {
512520 Value = contractResponseProduct . Value ,
513521 DisplayText = contractResponseProduct . DisplayText ,
@@ -523,23 +531,25 @@ public async Task<RedeemVoucherResponse> RedeemVoucher(Guid estateId,
523531 TransactionFees = new ( )
524532 } ;
525533
526- foreach ( TransactionProcessor . DataTransferObjects . Responses . Contract . ContractProductTransactionFee contractProductTransactionFee in contractResponseProduct . TransactionFees ) {
527- ContractProductTransactionFee transactionFeeModel = new ContractProductTransactionFee {
528- Value = contractProductTransactionFee . Value ,
529- Description = contractProductTransactionFee . Description ,
530- CalculationType = contractProductTransactionFee . CalculationType switch {
531- TransactionProcessor . DataTransferObjects . Responses . Contract . CalculationType . Fixed => CalculationType . Fixed ,
532- _ => CalculationType . Percentage ,
533- } ,
534- FeeType = contractProductTransactionFee . FeeType switch {
535- TransactionProcessor . DataTransferObjects . Responses . Contract . FeeType . Merchant => FeeType . Merchant ,
536- _ => FeeType . ServiceProvider ,
537- } ,
538- TransactionFeeId = contractProductTransactionFee . TransactionFeeId ,
539- TransactionFeeReportingId = contractProductTransactionFee . TransactionFeeReportingId
540- } ;
541- productModel . TransactionFees . Add ( transactionFeeModel ) ;
542- }
534+ // Leave here but not used atm
535+ //foreach (TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProductTransactionFee contractProductTransactionFee in contractResponseProduct.TransactionFees) {
536+ // Logger.LogInformation($"Processing contract product fee {contractProductTransactionFee.Description}");
537+ // ContractProductTransactionFee transactionFeeModel = new ContractProductTransactionFee {
538+ // Value = contractProductTransactionFee.Value,
539+ // Description = contractProductTransactionFee.Description,
540+ // CalculationType = contractProductTransactionFee.CalculationType switch {
541+ // TransactionProcessor.DataTransferObjects.Responses.Contract.CalculationType.Fixed => CalculationType.Fixed,
542+ // _ => CalculationType.Percentage,
543+ // },
544+ // FeeType = contractProductTransactionFee.FeeType switch {
545+ // TransactionProcessor.DataTransferObjects.Responses.Contract.FeeType.Merchant => FeeType.Merchant,
546+ // _ => FeeType.ServiceProvider,
547+ // },
548+ // TransactionFeeId = contractProductTransactionFee.TransactionFeeId,
549+ // TransactionFeeReportingId = contractProductTransactionFee.TransactionFeeReportingId
550+ // };
551+ // productModel.TransactionFees.Add(transactionFeeModel);
552+ //}
543553
544554 contractModel . Products . Add ( productModel ) ;
545555 }
0 commit comments