private Dictionary <string, List <string> > GetPartnermerchantIds(Merchant merchant)
        {
            Dictionary <string, List <string> > partnerIds = new Dictionary <string, List <string> >();

            Log.Info($"[{nameof(GetPartnermerchantIds)}] Processing merchant {merchant.Name}");

            foreach (var payment in merchant.Payments)
            {
                if (payment.Processor == PaymentProcessor.MasterCard)
                {
                    string masterCardMid = ProcessMasterCardMid(merchant.Name, payment);
                    if (masterCardMid != null)
                    {
                        if (!partnerIds.ContainsKey(PaymentProcessor.MasterCard.ToString()))
                        {
                            partnerIds[PaymentProcessor.MasterCard.ToString()] =
                                new List <string> {
                                masterCardMid
                            }
                        }
                        ;
                        else
                        {
                            partnerIds[PaymentProcessor.MasterCard.ToString()].Add(masterCardMid);
                        }
                        Log.Info($"Added MasterCardMID {masterCardMid} of PaymentId {payment.Id} to PartnerMids collection for {merchant.Name}");
                    }
                }
                else if (payment.Processor == PaymentProcessor.Visa)
                {
                    string visaMid = ProcessVisaMid(merchant.Name, payment);
                    if (!string.IsNullOrWhiteSpace(visaMid))
                    {
                        if (!partnerIds.ContainsKey(PaymentProcessor.Visa.ToString()))
                        {
                            partnerIds[PaymentProcessor.Visa.ToString()] =
                                new List <string> {
                                visaMid
                            }
                        }
                        ;
                        else
                        {
                            partnerIds[PaymentProcessor.Visa.ToString()].Add(visaMid);
                        }
                        Log.Info($"Added VisaMID {visaMid} of PaymentId {payment.Id} to PartnerMids collection for {merchant.Name}");
                    }
                }
                else if (payment.Processor == PaymentProcessor.Amex)
                {
                    string amexSeNumber = payment.PaymentMids.ContainsKey(MerchantConstants.AmexSENumber) ? payment.PaymentMids[MerchantConstants.AmexSENumber] : null;
                    if (!string.IsNullOrWhiteSpace(amexSeNumber))
                    {
                        // Upload it to commerce for further processing
                        string detailRecord = new OfferRegistrationDetail()
                        {
                            ActionCode        = OfferRegistrationActionCodeType.Add, // Need to update if already added Merchant
                            MerchantName      = merchant.Name,
                            MerchantNumber    = amexSeNumber,
                            MerchantEndDate   = DateTime.UtcNow.AddYears(10),
                            MerchantId        = merchant.Id,
                            OfferName         = "Earn Offer",
                            MerchantStartDate = DateTime.UtcNow
                        }.BuildFileDetailRecord();

                        string       blobName     = "ToBeProcessed/" + amexSeNumber + "-" + GuidUtility.GenerateShortGuid() + ".txt";
                        byte[]       contentBytes = Encoding.ASCII.GetBytes(detailRecord);
                        MemoryStream ms           = new MemoryStream(contentBytes);
                        ms.Position = 0;
                        Task task = MerchantRegistrationAzureBlob.UploadBlobFromStreamAsync("amex-offer-registrationrecords", blobName, ms);

                        // commerce registration
                        string formattedSeNumber = $"{amexSeNumber};1";
                        if (!partnerIds.ContainsKey(PaymentProcessor.Amex.ToString()))
                        {
                            partnerIds[PaymentProcessor.Amex.ToString()] = new List <string> {
                                formattedSeNumber
                            }
                        }
                        ;
                        else
                        {
                            partnerIds[PaymentProcessor.Amex.ToString()].Add(formattedSeNumber);
                        }

                        Task.WaitAny(task);
                        Log.Info($"Added Amex SEnumber {formattedSeNumber} of PaymentId {payment.Id} to PartnerMids collection for {merchant.Name}");
                    }
                }
            }

            return(partnerIds);
        }