Example #1
0
        public ServiceResult ModifyIdentity(ModifyIdentityModel model)
        {
            var result = new ServiceResult();

            if (!ModelState.IsValid)
            {
                result.Code = ReasonCode.MISSING_REQUIRED_FIELDS;
                foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)))
                {
                    result.Message += error + Environment.NewLine;
                }

                return(result);
            }

            var accountId = this.GetMerchantAccountId();
            var profile   = new MerchantProfile
            {
                MerchantId      = accountId,
                IdentityDocNo   = model.IdentityDocNo,
                IdentityDocType = model.IdentityDocType
            };

            new ProfileComponent().ModifyIdentity(profile);


            return(result);
        }
Example #2
0
        public void ModifyCellphone(Guid accountId, string cellphone)
        {
            var dac     = new MerchantAccountDAC();
            var account = dac.GetById(accountId);

            SecurityVerify.Verify <ModifyCellphoneVerify>(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, account.Id.ToString(), (model) =>
            {
                return(model.PinVerified && model.NewCellphoneVerified && model.CombinedVerified);
            });

            if (account.Cellphone == cellphone)
            {
                throw new CommonException(10000, Resources.新手机号码不能与原来的一致);
            }

            //修改手机号
            dac.UpdateCellphone(accountId, cellphone);

            var agent   = new MerchantProfileAgent();
            var profile = new MerchantProfile
            {
                MerchantId = accountId,
                Cellphone  = cellphone,
                Country    = account.CountryId
            };

            agent.UpdateCellphone(profile);
        }
Example #3
0
        public ServiceResult CommitIdentityImage(CommitIdentityModel model)
        {
            var result = new ServiceResult();

            if (!ModelState.IsValid)
            {
                result.Code = ReasonCode.MISSING_REQUIRED_FIELDS;
                foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)))
                {
                    result.Message += error + Environment.NewLine;
                }

                return(result);
            }

            var accountId = this.GetMerchantAccountId();

            var profile = new MerchantProfile
            {
                MerchantId         = accountId,
                BackIdentityImage  = model.BackIdentityImage,
                FirstName          = model.FirstName,
                FrontIdentityImage = model.FrontIdentityImage,
                HandHoldWithCard   = model.HandHoldWithCard,
                IdentityDocNo      = model.IdentityDocNo,
                IdentityDocType    = model.IdentityDocType,
                LastName           = model.LastName,
                L1VerifyStatus     = VerifyStatus.UnderApproval
            };

            new ProfileComponent().CommitIdentityImage(profile);


            return(result);
        }
Example #4
0
        public ServiceResult CommitBusinessLicense(CommitBusinessLicenseModel model)
        {
            var result = new ServiceResult();

            if (!ModelState.IsValid)
            {
                result.Code = ReasonCode.MISSING_REQUIRED_FIELDS;
                foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)))
                {
                    result.Message += error + Environment.NewLine;
                }

                return(result);
            }

            var accountId = this.GetMerchantAccountId();
            var profile   = new MerchantProfile
            {
                MerchantId           = accountId,
                LicenseNo            = model.Number,
                BusinessLicenseImage = model.Image,
                CompanyName          = model.Name
            };

            new ProfileComponent().CommitBusinessLicense(profile);


            return(result);
        }
 public bool ModifyCellphone(MerchantProfile profile)
 {
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE MerchantProfiles SET Cellphone = @Cellphone WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
 public bool ModifyIdentity(MerchantProfile profile)
 {
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE MerchantProfiles SET IdentityDocNo=@IdentityDocNo,L1SubmissionDate=GETUTCDATE() WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
 public bool ModifyFullname(MerchantProfile profile)
 {
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE MerchantProfiles SET LastName=@LastName,FirstName=@FirstName,L1SubmissionDate=GETUTCDATE() WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
Example #8
0
        public ServiceResult <bool> CommitBusinessLicense(MerchantProfile profile)
        {
            bool result            = false;
            MerchantProfileDAC dac = new MerchantProfileDAC();

            result = dac.CommitBusinessLicense(profile);
            return(ResultHelper.OKResult(result));
        }
Example #9
0
        public ServiceResult <bool> UpdateCellphone(MerchantProfile profile)
        {
            bool result            = false;
            MerchantProfileDAC dac = new MerchantProfileDAC();

            result = dac.ModifyCellphone(profile);
            return(ResultHelper.OKResult(result));
        }
Example #10
0
        public ServiceResult <bool> CommitIdentityImage(MerchantProfile profile)
        {
            bool result            = false;
            MerchantProfileDAC dac = new MerchantProfileDAC();

            result = dac.CommitIdentityImage(profile);
            return(ResultHelper.OKResult(result));
        }
Example #11
0
        public ServiceResult <bool> ModifyAddress2(MerchantProfile profile)
        {
            bool result            = false;
            MerchantProfileDAC dac = new MerchantProfileDAC();

            result = dac.ModifyAddress2(profile);
            return(ResultHelper.OKResult(result));
        }
Example #12
0
 public bool ModifyAddress1(MerchantProfile profile)
 {
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE MerchantProfiles SET Address1=@Address1,Postcode=@Postcode,City=@City,State=@State,L2SubmissionDate=GETUTCDATE()  WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
Example #13
0
 public bool ModifyAddress2(MerchantProfile profile)
 {
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE MerchantProfiles SET Address2=@Address2 WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, new { }) > 0);
     }
 }
Example #14
0
        public SaveResult SaveMerchantProfileVerifyL1(int AdminId, string AdminName, MerchantProfile profile)
        {
            var oldProfile      = GetMerchantProfile(profile.MerchantId);
            var merchantAccount = FiiiPayDB.MerchantAccountDb.GetById(profile.MerchantId);

            merchantAccount.L1VerifyStatus = profile.L1VerifyStatus;
            if (oldProfile == null)
            {
                return(new SaveResult(false, "Data error"));
            }

            var profileSDK   = new MerchantProfileAgent();
            var verifyStatus = profileSDK.UpdateL1VerifyStatus(oldProfile.MerchantId, profile.L1VerifyStatus, profile.L1Remark);

            if (verifyStatus)
            {
                FiiiPayDB.MerchantAccountDb.Update(merchantAccount);
                if ((profile.L1VerifyStatus == VerifyStatus.Certified || profile.L1VerifyStatus == VerifyStatus.Disapproval))
                {
                    var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords()
                    {
                        AccountId  = profile.MerchantId,
                        Username   = merchantAccount.Username,
                        Body       = profile.L1Remark,
                        Type       = profile.L1VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.MerchantLv1Verified : VerifyRecordType.MerchantLv1Reject,
                        CreateTime = DateTime.UtcNow
                    });
                    try
                    {
                        if (profile.L1VerifyStatus == VerifyStatus.Certified)
                        {
                            RabbitMQSender.SendMessage("MerchantLv1Verified", recordId);
                        }
                        else if (profile.L1VerifyStatus == VerifyStatus.Disapproval)
                        {
                            RabbitMQSender.SendMessage("MerchantLv1VerifiedFailed", recordId);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message);
                    }
                }
            }


            ActionLog actionLog = new ActionLog();

            actionLog.AccountId  = AdminId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(MerchantProfileBLL).FullName + ".SaveMerchantProfileVerifyL1";
            actionLog.Username   = AdminName;
            actionLog.LogContent = string.Format("verify merchant profile.MerchantId:{0},l1verifystatus:{1}", profile.MerchantId, profile.L1VerifyStatus.ToString());
            new ActionLogBLL().Create(actionLog);

            return(new SaveResult(verifyStatus));
        }
Example #15
0
 public bool CommitIdentityImage(MerchantProfile profile)
 {
     profile.L1VerifyStatus = VerifyStatus.UnderApproval;
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE [MerchantProfiles] SET FirstName = @FirstName, LastName = @LastName, IdentityDocType = @IdentityDocType, IdentityDocNo = @IdentityDocNo, FrontIdentityImage = @FrontIdentityImage, BackIdentityImage = @BackIdentityImage, HandHoldWithCard = @HandHoldWithCard, L1VerifyStatus=@L1VerifyStatus,L1SubmissionDate=GETUTCDATE() WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
Example #16
0
 public bool CommitBusinessLicense(MerchantProfile profile)
 {
     profile.L2VerifyStatus = VerifyStatus.UnderApproval;
     using (var con = WriteConnection())
     {
         string SQL = "UPDATE [MerchantProfiles] SET BusinessLicenseImage=@BusinessLicenseImage,LicenseNo=@LicenseNo,L2VerifyStatus=@L2VerifyStatus,CompanyName=@CompanyName WHERE MerchantId=@MerchantId";
         return(con.Execute(SQL, profile) > 0);
     }
 }
Example #17
0
 public bool Insert(MerchantProfile model)
 {
     using (var con = WriteConnection())
     {
         //Address1,Postcode,City,State
         return(con.Execute(@"INSERT INTO MerchantProfiles([MerchantId],[LastName],[FirstName],[L1VerifyStatus],[L2VerifyStatus],[IdentityDocNo],[IdentityDocType],[IdentityExpiryDate],[Address1],[Address2],[City],[State],[Postcode],[Country],[FrontIdentityImage],[BackIdentityImage],[HandHoldWithCard],[BusinessLicenseImage],[LicenseNo],[CompanyName],[L1Remark],[L2Remark],[Cellphone],[L1SubmissionDate],[L2SubmissionDate]) VALUES(
                                                           @MerchantId,@LastName,@FirstName,@L1VerifyStatus,@L2VerifyStatus,@IdentityDocNo,@IdentityDocType,@IdentityExpiryDate,@Address1,@Address2,@City,@State,@Postcode,@Country,@FrontIdentityImage,@BackIdentityImage,@HandHoldWithCard,@BusinessLicenseImage,@LicenseNo,@CompanyName,@L1Remark,@L2Remark,@Cellphone,@L1SubmissionDate,@L2SubmissionDate)", model) > 0);
     }
 }
Example #18
0
        public void CommitIdentityImage(MerchantProfile profile)
        {
            var agent = new MerchantProfileAgent();
            var sr    = agent.CommitIdentityImage(profile);

            if (sr)
            {
                new MerchantAccountDAC().UpdateL1VerfiyStatus(profile.MerchantId, (byte)VerifyStatus.UnderApproval);
            }
        }
Example #19
0
        /// <summary>
        /// 获取全局数据库的商家个人信息
        /// </summary>
        /// <param name="merchantId"></param>
        /// <returns></returns>
        public MerchantProfile GetMerchantProfile(Guid merchantId)
        {
            MerchantProfileAgent agent   = new MerchantProfileAgent();
            MerchantProfile      profile = agent.GetMerchantProfile(merchantId);

            if (profile == null)
            {
                throw new CommonException(ReasonCode.FiiiPosReasonCode.ACCOUNT_NOT_EXISTS, "当前商家个人资料不存在");
            }
            return(profile);
        }
Example #20
0
        /// <summary>
        /// 修改商家执照认证
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="licenseNo"></param>
        /// <param name="businessLicense"></param>
        /// <returns>-1=修改失败 -2=已认证 -3=审核中 1=修改成功</returns>
        public void UpdateMerchantLicense(Guid merchantId, string companyName, string licenseNo, Guid businessLicense)
        {
            MerchantProfileAgent agent   = new MerchantProfileAgent();
            MerchantProfile      profile = agent.GetMerchantProfile(merchantId);

            if (profile.L2VerifyStatus == VerifyStatus.Certified || profile.L2VerifyStatus == VerifyStatus.UnderApproval)
            {
                throw new CommonException(ReasonCode.FiiiPosReasonCode.VERIFYED_STATUS, "已审核的用户不能更改该信息");
            }
            agent.UpdateMerchantLicense(merchantId, companyName, licenseNo, businessLicense);
        }
Example #21
0
        public bool Delete(MerchantProfile profile)
        {
            var url    = $"{baseAddress}/RemoveMerchant";
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(profile));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Example #22
0
        public void ModifyIdentity(MerchantProfile profile)
        {
            var agent = new MerchantProfileAgent();

            //需求改变,FIIIPOS的KYC无需证件号限制
            //int count = agent.GetCountByIdentityDocNo(profile.MerchantId, profile.IdentityDocNo);
            //if (count >= Constant.IDENTITY_LIMIT)
            //{
            //    throw new CommonException(ReasonCode.IDENTITYNO_USED_OVERLIMIT, Resources.IdentityUsedOverLimit);
            //}

            agent.ModifyIdentity(profile);
        }
        public bool AddMerchant(MerchantProfile profile)
        {
            var server = ProfileFactory.GetByCountryId(profile.Country);

            if (server == null)
            {
                throw new InvalidProfileServiceException();
            }
            else
            {
                MerchantProfileRPC dac = new MerchantProfileRPC(server);
                return(dac.Insert(profile));
            }
        }
Example #24
0
        /// <summary>
        /// 修改地址
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="postCode"></param>
        /// <param name="address1"></param>
        /// <param name="address2"></param>
        /// <returns></returns>
        public void UpdateAddress(Guid merchantId, string postCode, string address, string state, string city)
        {
            MerchantProfile model = new MerchantProfile();

            model.Address1   = address;
            model.MerchantId = merchantId;
            model.Postcode   = postCode;
            model.City       = city;
            model.State      = state;

            MerchantProfileAgent agent = new MerchantProfileAgent();

            agent.ModifyAddress1(model);
        }
Example #25
0
        internal bool ModifyAddress1(MerchantProfile profile)
        {
            var url      = $"{baseAddress}/ModifyAddress1";
            var paramStr = JsonConvert.SerializeObject(profile);
            var result   = RestUtilities.PostJson(url, headers, paramStr);

            _log.Info($"url: {url},param: {paramStr},  result: {result}");

            var data = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Example #26
0
        public void CommitIdentityImage(MerchantProfile profile)
        {
            var agent    = new MerchantProfileAgent();
            var merchant = new MerchantAccountDAC().GetById(profile.MerchantId);

            if (merchant.L1VerifyStatus != VerifyStatus.Uncertified && merchant.L1VerifyStatus != VerifyStatus.Disapproval)
            {
                throw new CommonException(ReasonCode.FiiiPosReasonCode.COMMITTED_STATUS, "该状态下不能提交审核。");
            }
            var sr = agent.CommitIdentityImage(profile);

            if (sr)
            {
                new MerchantAccountDAC().UpdateL1VerfiyStatus(profile.MerchantId, (byte)VerifyStatus.UnderApproval);
            }
        }
        public bool RemoveMerchantById(MerchantProfile profile)
        {
            if (profile.Country == 0)
            {
                throw new Exception("必须设置Profile的国家字段");
            }
            var server = ProfileFactory.GetByCountryId(profile.Country);

            if (server == null)
            {
                throw new InvalidProfileServiceException();
            }
            else
            {
                MerchantProfileRPC dac = new MerchantProfileRPC(server);
                return(dac.Delete(profile));
            }
        }
 public bool UpdateCellphone(MerchantProfile profile)
 {
     try
     {
         var server = ProfileFactory.GetByCountryId(profile.Country);
         if (server == null)
         {
             throw new InvalidProfileServiceException();
         }
         else
         {
             MerchantProfileRPC merchantProfileDAC = new MerchantProfileRPC(server);
             //赋值
             return(merchantProfileDAC.UpdateCellphone(profile));
         }
     }
     catch
     {
         return(false);
     }
 }
        public bool ModifyIdentity(MerchantProfile profile)
        {
            MerchantAccountDAC accountDAC = new MerchantAccountDAC();
            var account = accountDAC.GetById(profile.MerchantId);

            if (account == null)
            {
                return(false);
            }
            var server = ProfileFactory.GetByCountryId(account.CountryId);

            if (server == null)
            {
                throw new InvalidProfileServiceException();
            }
            else
            {
                MerchantProfileRPC dac = new MerchantProfileRPC(server);
                return(dac.ModifyIdentity(profile));
            }
        }
        /// <summary>
        /// 获得商家Profile信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public MerchantProfile GetMerchantProfile(Guid id)
        {
            MerchantAccountDAC merchantAccountDAC = new MerchantAccountDAC();
            var merchantAccount = merchantAccountDAC.GetById(id);

            if (merchantAccount == null)
            {
                return(null);//查无此人
            }
            var             router  = ProfileFactory.GetByCountryId(merchantAccount.CountryId);
            MerchantProfile profile = null;

            if (router == null)
            {
                throw new InvalidProfileServiceException();
            }
            else
            {
                MerchantProfileRPC dac = new MerchantProfileRPC(router);
                profile = dac.GetById(id);
            }
            return(profile);
        }
        public static MerchantProfile CreateMerchantProfile()
        {
            MerchantProfile merchData = new MerchantProfile();

            merchData.LastUpdated = DateTime.UtcNow;
            //MerchantData : https://my.ipcommerce.com/Docs/TransactionProcessing/CWS/API_Reference/2.0.18/ServiceInfoDataElements/MerchantProfileMerchantData.aspx
            merchData.MerchantData = new MerchantProfileMerchantData();
            //Address
            merchData.MerchantData.Address = new schemas.ipcommerce.com.Ipc.General.WCF.Contracts.Common.External.SvcInfo.AddressInfo();
            merchData.MerchantData.Address.City = "Pleasanton";
            merchData.MerchantData.Address.CountryCode = schemas.ipcommerce.com.Ipc.General.WCF.Contracts.Common.External.SvcInfo.TypeISOCountryCodeA3.USA;
            merchData.MerchantData.Address.PostalCode = "94566";
            merchData.MerchantData.Address.StateProvince = schemas.ipcommerce.com.Ipc.General.WCF.Contracts.Common.External.SvcInfo.TypeStateProvince.CA;
            merchData.MerchantData.Address.Street1 = "123 Merch address";
            merchData.MerchantData.Address.Street2 = "";
            merchData.MerchantData.CustomerServiceInternet = "*****@*****.**";
            merchData.MerchantData.CustomerServicePhone = "303 5553232";
            merchData.MerchantData.Language = TypeISOLanguageCodeA3.ENG;
            merchData.MerchantData.MerchantId = "123456789012";
            merchData.MerchantData.Name = "Test Merch";
            merchData.MerchantData.Phone = "720 8881212";
            merchData.MerchantData.TaxId = "";

            //BankcardMerchantData : https://my.ipcommerce.com/Docs/TransactionProcessing/CWS/API_Reference/2.0.18/ServiceInfoDataElements/BankcardMerchantData.aspx
            merchData.MerchantData.BankcardMerchantData = new BankcardMerchantData();
            merchData.MerchantData.BankcardMerchantData.ABANumber = "987654321";
            merchData.MerchantData.BankcardMerchantData.AcquirerBIN = "654321";
            merchData.MerchantData.BankcardMerchantData.AgentBank = "123456";
            merchData.MerchantData.BankcardMerchantData.AgentChain = "645231";
            merchData.MerchantData.BankcardMerchantData.Aggregator = false;
            merchData.MerchantData.BankcardMerchantData.ClientNumber = "1234";
            merchData.MerchantData.BankcardMerchantData.IndustryType = _ITV._IndustryType;
            merchData.MerchantData.BankcardMerchantData.Location = "12345";
            merchData.MerchantData.BankcardMerchantData.MerchantType = "";
            merchData.MerchantData.BankcardMerchantData.PrintCustomerServicePhone = false;
            merchData.MerchantData.BankcardMerchantData.QualificationCodes = "";
            merchData.MerchantData.BankcardMerchantData.ReimbursementAttribute = "A";
            merchData.MerchantData.BankcardMerchantData.SIC = "5999";
            merchData.MerchantData.BankcardMerchantData.SecondaryTerminalId = "12345678";
            merchData.MerchantData.BankcardMerchantData.SettlementAgent = "12AB";
            merchData.MerchantData.BankcardMerchantData.SharingGroup = "123ABC";
            merchData.MerchantData.BankcardMerchantData.StoreId = "1234";
            merchData.MerchantData.BankcardMerchantData.TerminalId = "001";
            merchData.MerchantData.BankcardMerchantData.TimeZoneDifferential = "005";
            //ElectronicCheckingMerchantData : https://my.ipcommerce.com/Docs/TransactionProcessing/CWS/API_Reference/2.0.18/ServiceInfoDataElements/ElectronicCheckingMerchantData.aspx
            merchData.MerchantData.ElectronicCheckingMerchantData = new ElectronicCheckingMerchantData();
            merchData.MerchantData.ElectronicCheckingMerchantData.OrginatorId = "";
            merchData.MerchantData.ElectronicCheckingMerchantData.ProductId = "";
            merchData.MerchantData.ElectronicCheckingMerchantData.SiteId = "";
            //StoredValueMerchantData : https://my.ipcommerce.com/Docs/TransactionProcessing/CWS/API_Reference/2.0.18/ServiceInfoDataElements/StoredValueMerchantData.aspx
            merchData.MerchantData.StoredValueMerchantData = new StoredValueMerchantData();
            merchData.MerchantData.StoredValueMerchantData.AgentChain = "";
            merchData.MerchantData.StoredValueMerchantData.ClientNumber = "";
            merchData.MerchantData.StoredValueMerchantData.IndustryType = _ITV._IndustryType;
            merchData.MerchantData.StoredValueMerchantData.SIC = "";
            merchData.MerchantData.StoredValueMerchantData.StoreId = "";
            merchData.MerchantData.StoredValueMerchantData.TerminalId = "";

            //TransactionData
            merchData.TransactionData = new MerchantProfileTransactionData();
            merchData.TransactionData.BankcardTransactionDataDefaults = new BankcardTransactionDataDefaults();
            merchData.TransactionData.BankcardTransactionDataDefaults.CurrencyCode = schemas.ipcommerce.com.Ipc.General.WCF.Contracts.Common.External.SvcInfo.TypeISOCurrencyCodeA3.USD;
            merchData.TransactionData.BankcardTransactionDataDefaults.CustomerPresent = _ITV._CustomerPresent;
            merchData.TransactionData.BankcardTransactionDataDefaults.EntryMode = _ITV._EntryMode;
            merchData.TransactionData.BankcardTransactionDataDefaults.RequestACI = _ITV._RequestACI;
            merchData.TransactionData.BankcardTransactionDataDefaults.RequestAdvice = schemas.ipcommerce.com.Ipc.General.WCF.Contracts.Common.External.SvcInfo.RequestAdvice.Capable;

            return merchData;
        }
        private void cboAvailableProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            Item item = (Item)cboAvailableProfiles.SelectedItem;
            Helper.MerchantProfileId = item.Value1;

            //Let's check to see if the profile is initialized.
            //The IsMerchantProfileInitialized() operation can be used to verify that a specific Merchant Profile has been 
            //initialized (saved at least once).
            if (Helper.Cwssic.IsMerchantProfileInitialized(Helper.SessionToken, Helper.ServiceID, Helper.MerchantProfileId, TenderType.Credit))
            { 
                lblIsProfileInitialized.Text = "IsMerchantProfileInitialized : True";
                lblIsProfileInitialized.ForeColor = System.Drawing.Color.Green;
                //We now have something to persiste
                cmdPersistConfig.Enabled = true;
                cmdDeletePersistCached.Enabled = true;
                txtPersistedAndCached.Text = "*** Updated Value Ready for Persistence ***\r\nApplicationProfileId : " + Helper.ApplicationProfileId + "\r\nServiceId : " + Helper.ServiceID + "\r\nMerchantProfileId : " + Helper.MerchantProfileId;
            }
            else
            { 
                lblIsProfileInitialized.Text = "IsMerchantProfileInitialized : False";
                lblIsProfileInitialized.ForeColor = System.Drawing.Color.Red;
                txtPersistedAndCached.Text = "*** Updated Value Ready for Persistence ***\r\nApplicationProfileId : " + Helper.ApplicationProfileId + "\r\nServiceId : " + Helper.ServiceID + "\r\nMerchantProfileId : " + Helper.MerchantProfileId;
            }

            //let's get the specific profile
            //The GetMerchantProfile() operation retrieves a specific Merchant Profile for a specific service and tender type.
            _merP = Helper.Cwssic.GetMerchantProfile(Helper.SessionToken, Helper.MerchantProfileId, Helper.ServiceID, TenderType.Credit);
            
            cmdUpdateProfile.Enabled = true;
        }
        private void SaveMerchantInformation()
        {
            List<MerchantProfile> MPList = new List<MerchantProfile>();
            MerchantProfile MerP = new MerchantProfile();

            MerP.ProfileId = txtProfileId.Text;
            MerP.MerchantData = new MerchantProfileMerchantData();
            MerP.MerchantData.Address = new AddressInfo();
            //MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();
            
            MerP.TransactionData = new MerchantProfileTransactionData();
           
            
            MerP.MerchantData.Address.Street1 = txtStreetAddress1.Text;
            MerP.MerchantData.Address.Street2 = txtStreetAddress2.Text;
            MerP.MerchantData.Address.City = txtCity.Text;
            try{ MerP.MerchantData.Address.StateProvince = (TypeStateProvince) Enum.Parse(typeof (TypeStateProvince), txtStateProvince.Text);}
            catch{}
            MerP.MerchantData.Address.PostalCode = txtPostalCode.Text;
            MerP.MerchantData.CustomerServicePhone = txtCustomerServicePhone.Text;
            MerP.MerchantData.CustomerServiceInternet = txtCustomerServiceInternet.Text;
            MerP.MerchantData.MerchantId = txtMerchantId.Text;
            MerP.MerchantData.Name = txtName.Text;
            MerP.MerchantData.Phone = txtPhone.Text;
            MerP.MerchantData.TaxId = txtTaxId.Text;
            MerP.MerchantData.Language = _Language;
            MerP.MerchantData.Address.CountryCode = _CountryCode;

            MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();

            if (_bcs != null)
            {
                MerP.TransactionData.BankcardTransactionDataDefaults = new BankcardTransactionDataDefaults();
                MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();
                MerP.MerchantData.BankcardMerchantData.ClientNumber = txtClientNum.Text;
                MerP.MerchantData.BankcardMerchantData.SIC = txtSIC.Text;
                MerP.MerchantData.BankcardMerchantData.TerminalId = txtSocketNum.Text;
                MerP.MerchantData.BankcardMerchantData.StoreId = txtStoreId.Text;
                MerP.TransactionData.BankcardTransactionDataDefaults.CurrencyCode = _CurrencyCode;
                MerP.TransactionData.BankcardTransactionDataDefaults.CustomerPresent = _CustomerPresent;
                MerP.TransactionData.BankcardTransactionDataDefaults.RequestACI = _RequestACI;
                MerP.TransactionData.BankcardTransactionDataDefaults.RequestAdvice = RequestAdvice.Capable;
                MerP.TransactionData.BankcardTransactionDataDefaults.EntryMode = _EntryMode;

                // Tsys Terminal Capture Siera
                MerP.MerchantData.BankcardMerchantData.ABANumber = txtABANumber.Text;
                MerP.MerchantData.BankcardMerchantData.AcquirerBIN = txtAcquirerBIN.Text;
                MerP.MerchantData.BankcardMerchantData.AgentBank = txtAgentBank.Text;
                MerP.MerchantData.BankcardMerchantData.AgentChain = txtAgentChain.Text;
                MerP.MerchantData.BankcardMerchantData.Location = txtLocation.Text;
                MerP.MerchantData.BankcardMerchantData.SecondaryTerminalId = txtSecondaryTerminalId.Text;
                MerP.MerchantData.BankcardMerchantData.SettlementAgent = txtSettlementAgent.Text;
                MerP.MerchantData.BankcardMerchantData.SharingGroup = txtSharingGroup.Text;
                MerP.MerchantData.BankcardMerchantData.TimeZoneDifferential = txtTimeZoneDifferential.Text;
                MerP.MerchantData.BankcardMerchantData.ReimbursementAttribute = txtReimbursementAttribute.Text;
                MerP.MerchantData.BankcardMerchantData.IndustryType = _MerchantIndustryType;
            }

            if (_ecks != null)
            {
                MerP.MerchantData.ElectronicCheckingMerchantData = new ElectronicCheckingMerchantData();
                MerP.MerchantData.ElectronicCheckingMerchantData.OrginatorId = txtMerchantId.Text;
                MerP.MerchantData.ElectronicCheckingMerchantData.ProductId = txtSocketNum.Text;
                MerP.MerchantData.ElectronicCheckingMerchantData.SiteId = txtStoreId.Text;
            }
            if (_svas != null)
            {
                MerP.MerchantData.StoredValueMerchantData = new StoredValueMerchantData();
                MerP.MerchantData.StoredValueMerchantData.AgentChain = txtAgentChain.Text;
                MerP.MerchantData.StoredValueMerchantData.ClientNumber = txtClientNum.Text;
                MerP.MerchantData.StoredValueMerchantData.SIC = txtSIC.Text;
                MerP.MerchantData.StoredValueMerchantData.StoreId = txtStoreId.Text;
                MerP.MerchantData.StoredValueMerchantData.TerminalId = txtSocketNum.Text;
                MerP.MerchantData.StoredValueMerchantData.IndustryType = _MerchantIndustryType;

            }
            
            //Add the profile to a list of profiles. This is necessary to save the profile
            MPList.Add(MerP);
            //From the calling form
            ((SampleCode_DeskTop)(Owner)).Helper.CheckTokenExpire();
            string _strServiceID = ((SampleCode_DeskTop)(Owner)).Helper.ServiceID;
            string _strSessionToken = ((SampleCode_DeskTop)(Owner)).Helper.SessionToken;

            if (ChkUseWorkFlowId.Checked)
            {
                ((SampleCode_DeskTop)(Owner)).Helper.Cwssic.SaveMerchantProfiles(_strSessionToken, ((SampleCode_DeskTop)(Owner)).Helper.WorkflowID, TenderType.Credit, MPList);
            }
            else
            {
                ((SampleCode_DeskTop)(Owner)).Helper.Cwssic.SaveMerchantProfiles(_strSessionToken, _strServiceID, TenderType.Credit, MPList);
            }
        }
        public void CallingForm(MerchantProfile merchantProfile, bool blnNewProfile, BankcardService bcs, ElectronicCheckingService ecks, StoredValueService svas, string serviceId)
        {
            _bcs = bcs;
            _ecks = ecks;
            _svas = svas;
            _strServiceID = serviceId;

            hideAllFields();
            //Since MerchantProfile is saved at the serviceId level, display serviceId.
            txtMerchantProfileServiceId.Text = merchantProfile.ServiceId;
            
            if(blnNewProfile)
            {//New profile to add to CWS
                cmdAddUpdate.Text = "Add";

                //Populate combo boxes with the Enumeration
                cboCountryCode.Sorted = true;
                cboCountryCode.DataSource = Enum.GetValues(typeof(TypeISOCountryCodeA3));
                cboCountryCode.SelectedItem = TypeISOCountryCodeA3.NotSet;

                cboLanguage.Sorted = true;
                cboLanguage.DataSource = Enum.GetValues(typeof(TypeISOLanguageCodeA3));
                cboLanguage.SelectedItem = TypeISOLanguageCodeA3.NotSet;

                cboCurrencyCode.Sorted = true;
                cboCurrencyCode.DataSource = Enum.GetValues(typeof(TypeISOCurrencyCodeA3));
                cboCurrencyCode.SelectedItem = TypeISOCurrencyCodeA3.NotSet;


                cboCustomerPresent.Sorted = true;
                cboCustomerPresent.DataSource = Enum.GetValues(typeof(CustomerPresent));
                cboCustomerPresent.SelectedItem = CustomerPresent.NotSet;

                cboRequestACI.Sorted = true;
                cboRequestACI.DataSource = Enum.GetValues(typeof(RequestACI));
                cboRequestACI.SelectedItem = RequestACI.IsCPSMeritCapable;

                cboEntryMode.Sorted = true;
                cboEntryMode.DataSource = Enum.GetValues(typeof(EntryMode));
                cboEntryMode.SelectedItem = EntryMode.NotSet;

                cboMerchantIndustryType.Sorted = true;
                cboMerchantIndustryType.DataSource = Enum.GetValues(typeof(IndustryType));
                cboMerchantIndustryType.SelectedItem = IndustryType.NotSet;
            }
            else
            {//Existing Profile to Update;
                //Note : items commented out are not use so no need to wire up a text box as well as add to 'SaveMerchantInformation()'
                txtProfileId.Text = merchantProfile.ProfileId;
                txtProfileId.ReadOnly = true;
                lblLastUpdated.Text = "Last Updated : " + merchantProfile.LastUpdated;
                //MerchantData
                //MerchantData.Address
                txtCity.Text = merchantProfile.MerchantData.Address.City;
                txtPostalCode.Text = merchantProfile.MerchantData.Address.PostalCode;
                txtStateProvince.Text = merchantProfile.MerchantData.Address.StateProvince.ToString();
                txtStreetAddress1.Text = merchantProfile.MerchantData.Address.Street1;
                txtStreetAddress2.Text = merchantProfile.MerchantData.Address.Street2;

                txtCustomerServiceInternet.Text = merchantProfile.MerchantData.CustomerServiceInternet;
                txtCustomerServicePhone.Text = merchantProfile.MerchantData.CustomerServicePhone;
                txtMerchantId.Text = merchantProfile.MerchantData.MerchantId;
                txtName.Text = merchantProfile.MerchantData.Name;
                txtPhone.Text = merchantProfile.MerchantData.Phone;
                txtTaxId.Text = merchantProfile.MerchantData.TaxId;
                if (_bcs != null)
                {
		                //MerchantData.BankcardMerchantData
		                txtABANumber.Text = merchantProfile.MerchantData.BankcardMerchantData.ABANumber;
		                txtAcquirerBIN.Text = merchantProfile.MerchantData.BankcardMerchantData.AcquirerBIN;
		                txtAgentBank.Text = merchantProfile.MerchantData.BankcardMerchantData.AgentBank;
		                txtAgentChain.Text = merchantProfile.MerchantData.BankcardMerchantData.AgentChain;
		                txtClientNum.Text = merchantProfile.MerchantData.BankcardMerchantData.ClientNumber;
		                txtLocation.Text = merchantProfile.MerchantData.BankcardMerchantData.Location;
		                //txtTBD.Text = _MerchantProfile.MerchantData.BankcardMerchantData.PrintCustomerServicePhone == "";
		                txtSecondaryTerminalId.Text = merchantProfile.MerchantData.BankcardMerchantData.SecondaryTerminalId;
		                txtSettlementAgent.Text = merchantProfile.MerchantData.BankcardMerchantData.SettlementAgent;
		                txtSharingGroup.Text = merchantProfile.MerchantData.BankcardMerchantData.SharingGroup;
		                txtSIC.Text = merchantProfile.MerchantData.BankcardMerchantData.SIC;
		                txtStoreId.Text = merchantProfile.MerchantData.BankcardMerchantData.StoreId;
		                txtSocketNum.Text = merchantProfile.MerchantData.BankcardMerchantData.TerminalId;
		                txtTimeZoneDifferential.Text = merchantProfile.MerchantData.BankcardMerchantData.TimeZoneDifferential;
		                txtReimbursementAttribute.Text = merchantProfile.MerchantData.BankcardMerchantData.ReimbursementAttribute;
              	}
              	if (_svas != null)
              	{
              			//MerchantData.StoredValueMerchantData
		                txtAgentChain.Text = merchantProfile.MerchantData.StoredValueMerchantData.AgentChain;
		                txtClientNum.Text = merchantProfile.MerchantData.StoredValueMerchantData.ClientNumber;
		                txtSIC.Text = merchantProfile.MerchantData.StoredValueMerchantData.SIC;
		                txtStoreId.Text = merchantProfile.MerchantData.StoredValueMerchantData.StoreId;
		                txtSocketNum.Text = merchantProfile.MerchantData.StoredValueMerchantData.TerminalId;
		                _MerchantIndustryType = merchantProfile.MerchantData.StoredValueMerchantData.IndustryType;
		            }
                    if (_ecks != null)
                    {
                        //MerchantData.ElectronicCheckingMerchantData
                        txtMerchantId.Text = merchantProfile.MerchantData.ElectronicCheckingMerchantData.OrginatorId;
                        txtStoreId.Text = merchantProfile.MerchantData.ElectronicCheckingMerchantData.SiteId;
                        txtSocketNum.Text = merchantProfile.MerchantData.ElectronicCheckingMerchantData.ProductId;
                    }

                //First Populate with the Enumeration
                cboCountryCode.DataSource = Enum.GetValues(typeof(TypeISOCountryCodeA3));
                //Now select the index that matches
                if (merchantProfile.MerchantData.Address.CountryCode.ToString().Length > 0)
                {
                    cboCountryCode.SelectedItem = merchantProfile.MerchantData.Address.CountryCode;
                    _CountryCode = (TypeISOCountryCodeA3)cboCountryCode.SelectedItem;
                }
                //First Populate with the Enumeration
                cboLanguage.DataSource = Enum.GetValues(typeof(TypeISOLanguageCodeA3));
                //Now select the index that matches
                if (merchantProfile.MerchantData.Language.ToString().Length > 0)
                {
                    cboLanguage.SelectedItem = merchantProfile.MerchantData.Language;
                    _Language = (TypeISOLanguageCodeA3)cboLanguage.SelectedItem;
                }
                //First Populate with the Enumeration
                cboCurrencyCode.DataSource = Enum.GetValues(typeof(TypeISOCurrencyCodeA3));
                //Now select the index that matches
                if (merchantProfile.MerchantData.Language.ToString().Length > 0)
                {
                    cboCurrencyCode.SelectedItem = merchantProfile.TransactionData.BankcardTransactionDataDefaults.CurrencyCode;
                    _CurrencyCode = (TypeISOCurrencyCodeA3)cboCurrencyCode.SelectedItem;
                }

                //First Populate with the Enumeration
                cboCustomerPresent.DataSource = Enum.GetValues(typeof(CustomerPresent));
                //Now select the index that matches
                if (merchantProfile.TransactionData.BankcardTransactionDataDefaults.CustomerPresent.ToString().Length > 0)
                {
                    cboCustomerPresent.SelectedItem = merchantProfile.TransactionData.BankcardTransactionDataDefaults.CustomerPresent;
                    _CustomerPresent = (CustomerPresent)cboCustomerPresent.SelectedItem;
                }

                //First Populate with the Enumeration
                cboRequestACI.DataSource = Enum.GetValues(typeof(RequestACI));
                //Now select the index that matches
                if (merchantProfile.TransactionData.BankcardTransactionDataDefaults.RequestACI.ToString().Length > 0)
                {
                    cboRequestACI.SelectedItem = merchantProfile.TransactionData.BankcardTransactionDataDefaults.RequestACI;
                    _RequestACI = (RequestACI)cboRequestACI.SelectedItem;
                }

                //First Populate with the Enumeration
                cboMerchantIndustryType.DataSource = Enum.GetValues(typeof(IndustryType));
                if (merchantProfile.MerchantData.BankcardMerchantData.IndustryType.ToString().Length > 0)
                {
                    cboMerchantIndustryType.SelectedItem = merchantProfile.MerchantData.BankcardMerchantData.IndustryType;
                    _MerchantIndustryType = (IndustryType)cboMerchantIndustryType.SelectedItem;
                }

                //First Populate with the Enumeration
                cboEntryMode.DataSource = Enum.GetValues(typeof(EntryMode));
                if (merchantProfile.TransactionData.BankcardTransactionDataDefaults.EntryMode.ToString().Length > 0)
                {
                    cboEntryMode.SelectedItem = merchantProfile.TransactionData.BankcardTransactionDataDefaults.EntryMode;
                    _EntryMode = (EntryMode)cboEntryMode.SelectedItem;
                }

                _Add = false; //In this case it's an update and not an add
                cmdAddUpdate.Text = "Update";
            }
            

            if (_bcs != null)
            {
                if (_strServiceID == "C82ED00001" || _strServiceID == "71C8700001" ||
                    _strServiceID == "88D9300001" || _strServiceID == "B447F00001" ||
                    _strServiceID == "D806000001" || _strServiceID == "E88FD00001")
                    showBCPExpandedFields();
                else if (_strServiceID == "168511300C" || _strServiceID == "9999999999")
                    showBCPExpandedFields();
                else
                {
                    showBCPFields();
                }
            }

            if (_ecks != null)
            {
                showECKFields();
            }
            if (_svas != null)
            {
                showSVAFields();
            }
        }
        public void CallingForm(MerchantProfile merchantProfile, bool blnNewProfile, BankcardService bcs, ElectronicCheckingService ecks, StoredValueService svas, string serviceId)
        {
            _bcs = bcs;
            _ecks = ecks;
            _svas = svas;
            _strServiceID = serviceId;

            hideAllFields();
            //Since MerchantProfile is saved at the serviceId level, display serviceId.
            //txtMerchantProfileServiceId.Text = merchantProfile.ServiceId;

            if (serviceId.Length < 1)
                txtMerchantProfileServiceId.Text = "ServiceId not selected in calling form";
            else
                txtMerchantProfileServiceId.Text = serviceId;

            //Populate combo boxes with the Enumeration
            cboCountryCode.Sorted = true;
            cboCountryCode.DataSource = Enum.GetValues(typeof(TypeISOCountryCodeA3));
            cboCountryCode.SelectedItem = TypeISOCountryCodeA3.NotSet;

            cboLanguage.Sorted = true;
            cboLanguage.DataSource = Enum.GetValues(typeof(TypeISOLanguageCodeA3));
            cboLanguage.SelectedItem = TypeISOLanguageCodeA3.NotSet;

            cboCurrencyCode.Sorted = true;
            cboCurrencyCode.DataSource = Enum.GetValues(typeof(TypeISOCurrencyCodeA3));
            cboCurrencyCode.SelectedItem = TypeISOCurrencyCodeA3.NotSet;

            cboCustomerPresent.Sorted = true;
            cboCustomerPresent.DataSource = Enum.GetValues(typeof(CustomerPresent));
            cboCustomerPresent.SelectedItem = CustomerPresent.NotSet;

            cboRequestACI.Sorted = true;
            cboRequestACI.DataSource = Enum.GetValues(typeof(RequestACI));
            cboRequestACI.SelectedItem = RequestACI.IsCPSMeritCapable;

            cboEntryMode.Sorted = true;
            cboEntryMode.DataSource = Enum.GetValues(typeof(EntryMode));
            cboEntryMode.SelectedItem = EntryMode.NotSet;

            cboMerchantIndustryType.Sorted = true;
            cboMerchantIndustryType.DataSource = Enum.GetValues(typeof(IndustryType));
            cboMerchantIndustryType.SelectedItem = IndustryType.NotSet;

            if (_bcs != null)
            {
                if (_strServiceID == "C82ED00001" || _strServiceID == "71C8700001" ||
                    _strServiceID == "88D9300001" || _strServiceID == "B447F00001" ||
                    _strServiceID == "D806000001" || _strServiceID == "E88FD00001")
                    showBCPExpandedFields();
                else if (_strServiceID == "168511300C" || _strServiceID == "9999999999")
                    showBCPExpandedFields();
                else
                {
                    showBCPFields();
                }
            }

            if (_ecks != null)
            {
                showECKFields();
            }
            if (_svas != null)
            {
                showSVAFields();
            }
        }
        private void SaveMerchantInformation()
        {
            List<MerchantProfile> MPList = new List<MerchantProfile>();
            MerchantProfile MerP = new MerchantProfile();

            MerP.ProfileId = cboAvailableProfiles.Text;
            MerP.MerchantData = new MerchantProfileMerchantData();
            MerP.MerchantData.Address = new AddressInfo();
            //MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();

            MerP.TransactionData = new MerchantProfileTransactionData();

            MerP.MerchantData.Address.Street1 = txtStreetAddress1.Text;
            MerP.MerchantData.Address.Street2 = txtStreetAddress2.Text;
            MerP.MerchantData.Address.City = txtCity.Text;
            try { MerP.MerchantData.Address.StateProvince = (TypeStateProvince)Enum.Parse(typeof(TypeStateProvince), txtStateProvince.Text); }
            catch { }
            MerP.MerchantData.Address.PostalCode = txtPostalCode.Text;
            MerP.MerchantData.CustomerServicePhone = txtCustomerServicePhone.Text;
            MerP.MerchantData.CustomerServiceInternet = txtCustomerServiceInternet.Text;
            MerP.MerchantData.MerchantId = txtMerchantId.Text;
            MerP.MerchantData.Name = txtName.Text;
            MerP.MerchantData.Phone = txtPhone.Text;
            MerP.MerchantData.TaxId = txtTaxId.Text;
            MerP.MerchantData.Language = _Language;
            MerP.MerchantData.Address.CountryCode = _CountryCode;

            MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();

            if (_bcs != null)
            {
                MerP.TransactionData.BankcardTransactionDataDefaults = new BankcardTransactionDataDefaults();
                MerP.MerchantData.BankcardMerchantData = new BankcardMerchantData();
                MerP.MerchantData.BankcardMerchantData.ClientNumber = txtClientNum.Text;
                MerP.MerchantData.BankcardMerchantData.SIC = txtSIC.Text;
                MerP.MerchantData.BankcardMerchantData.TerminalId = txtSocketNum.Text;
                MerP.MerchantData.BankcardMerchantData.StoreId = txtStoreId.Text;
                MerP.TransactionData.BankcardTransactionDataDefaults.CurrencyCode = _CurrencyCode;
                MerP.TransactionData.BankcardTransactionDataDefaults.CustomerPresent = _CustomerPresent;
                MerP.TransactionData.BankcardTransactionDataDefaults.RequestACI = _RequestACI;
                MerP.TransactionData.BankcardTransactionDataDefaults.RequestAdvice = RequestAdvice.Capable;
                MerP.TransactionData.BankcardTransactionDataDefaults.EntryMode = _EntryMode;

                // Terminal Capture other providers
                MerP.MerchantData.BankcardMerchantData.ABANumber = txtABANumber.Text;
                MerP.MerchantData.BankcardMerchantData.AcquirerBIN = txtAcquirerBIN.Text;
                MerP.MerchantData.BankcardMerchantData.AgentBank = txtAgentBank.Text;
                MerP.MerchantData.BankcardMerchantData.AgentChain = txtAgentChain.Text;
                MerP.MerchantData.BankcardMerchantData.Location = txtLocation.Text;
                MerP.MerchantData.BankcardMerchantData.SecondaryTerminalId = txtSecondaryTerminalId.Text;
                MerP.MerchantData.BankcardMerchantData.SettlementAgent = txtSettlementAgent.Text;
                MerP.MerchantData.BankcardMerchantData.SharingGroup = txtSharingGroup.Text;
                MerP.MerchantData.BankcardMerchantData.TimeZoneDifferential = txtTimeZoneDifferential.Text;
                MerP.MerchantData.BankcardMerchantData.ReimbursementAttribute = txtReimbursementAttribute.Text;
                MerP.MerchantData.BankcardMerchantData.IndustryType = _MerchantIndustryType;
            }

            if (_ecks != null)
            {
                MerP.MerchantData.ElectronicCheckingMerchantData = new ElectronicCheckingMerchantData();
                MerP.MerchantData.ElectronicCheckingMerchantData.OrginatorId = txtMerchantId.Text;
                MerP.MerchantData.ElectronicCheckingMerchantData.ProductId = txtSocketNum.Text;
                MerP.MerchantData.ElectronicCheckingMerchantData.SiteId = txtStoreId.Text;
            }
            if (_svas != null)
            {
                MerP.MerchantData.StoredValueMerchantData = new StoredValueMerchantData();
                MerP.MerchantData.StoredValueMerchantData.AgentChain = txtAgentChain.Text;
                MerP.MerchantData.StoredValueMerchantData.ClientNumber = txtClientNum.Text;
                MerP.MerchantData.StoredValueMerchantData.SIC = txtSIC.Text;
                MerP.MerchantData.StoredValueMerchantData.StoreId = txtStoreId.Text;
                MerP.MerchantData.StoredValueMerchantData.TerminalId = txtSocketNum.Text;
                MerP.MerchantData.StoredValueMerchantData.IndustryType = _MerchantIndustryType;

            }

            //Add the profile to a list of profiles. This is necessary to save the profile
            MPList.Add(MerP);
            //From the calling form
            ((SampleCode_DeskTop)(Owner)).Helper.CheckTokenExpire();
            string _strServiceID = ((SampleCode_DeskTop)(Owner)).Helper.ServiceID;
            string _strSessionToken = ((SampleCode_DeskTop)(Owner)).Helper.SessionToken;

            ((SampleCode_DeskTop)(Owner)).Helper.Cwssic.SaveMerchantProfiles(_strSessionToken, _strServiceID, TenderType.Credit, MPList);

            _Dirty = true; //When control is returned to calling form the form will re-generate service information.

            MessageBox.Show("Successfully Saved a Merchant Profile");

            //Reset the cboAvailableProfiles dropdown.
            cboAvailableProfiles.Items.Clear();
            cboAvailableProfiles.Text = "";
            //Now sync the new list
            ((SampleCode_DeskTop)(Owner)).GetMerchantProfileIds();
            foreach (var item in ((SampleCode_DeskTop)(Owner)).cboAvailableProfiles.Items)
            {
                cboAvailableProfiles.Items.Add(item);
            }
        }
        public static List<MerchantProfile> CreateMerchantProfiles()
        {
            var merchProfile = new MerchantProfile();
            merchProfile.ProfileId = ConfigurationManager.AppSettings["MerchantProfileId"];
            merchProfile.LastUpdated = DateTime.Now;

            merchProfile.MerchantData = new MerchantProfileMerchantData();
            merchProfile.MerchantData.CustomerServiceInternet = ConfigurationManager.AppSettings["CustomerServiceInternet"];
            merchProfile.MerchantData.CustomerServicePhone = ConfigurationManager.AppSettings["CustomerServicePhone"];
            merchProfile.MerchantData.Language = (TypeISOLanguageCodeA3)Enum.Parse(typeof(TypeISOLanguageCodeA3), ConfigurationManager.AppSettings["Language"]);
            merchProfile.MerchantData.MerchantId = ConfigurationManager.AppSettings["MerchantId"];
            merchProfile.MerchantData.Name = ConfigurationManager.AppSettings["Name"];
            merchProfile.MerchantData.Phone = ConfigurationManager.AppSettings["Phone"];

            merchProfile.MerchantData.BankcardMerchantData = new BankcardMerchantData();
            merchProfile.MerchantData.BankcardMerchantData.ABANumber = "128965";
            merchProfile.MerchantData.BankcardMerchantData.AgentChain = "1289";
            merchProfile.MerchantData.BankcardMerchantData.AgentBank = "1289";
            merchProfile.MerchantData.BankcardMerchantData.AcquirerBIN = "1248";
            merchProfile.MerchantData.BankcardMerchantData.Location = "108";
            merchProfile.MerchantData.BankcardMerchantData.PrintCustomerServicePhone = false;
            merchProfile.MerchantData.BankcardMerchantData.ReimbursementAttribute = "X";
            merchProfile.MerchantData.BankcardMerchantData.SettlementAgent = "0001";
            merchProfile.MerchantData.BankcardMerchantData.SharingGroup = "0001";
            merchProfile.MerchantData.BankcardMerchantData.StoreId = "0001";
            merchProfile.MerchantData.BankcardMerchantData.SecondaryTerminalId = "751";
            merchProfile.MerchantData.BankcardMerchantData.TimeZoneDifferential = "750";
            merchProfile.MerchantData.BankcardMerchantData.IndustryType =(IndustryType)Enum.Parse(typeof(IndustryType), ConfigurationManager.AppSettings["IndustryType"]);
            merchProfile.MerchantData.BankcardMerchantData.SIC = "4599"; // Required, Standard Industry Code
            merchProfile.MerchantData.BankcardMerchantData.ClientNumber = "1234"; // Optional - Required for Chase
            merchProfile.MerchantData.BankcardMerchantData.Aggregator = Boolean.Parse(ConfigurationManager.AppSettings["Pro_IncludeAlternativeMerchantData"]);
            merchProfile.MerchantData.BankcardMerchantData.TerminalId = "001";

            merchProfile.MerchantData.Address = new AddressInfo();
            merchProfile.MerchantData.Address.Street1 = ConfigurationManager.AppSettings["MerchStreet1"];
            merchProfile.MerchantData.Address.Street2 = string.IsNullOrEmpty(ConfigurationManager.AppSettings["MerchStreet2"]) ? null : ConfigurationManager.AppSettings["MerchStreet2"];
            merchProfile.MerchantData.Address.City = ConfigurationManager.AppSettings["MerchCity"];
            merchProfile.MerchantData.Address.StateProvince = (TypeStateProvince)Enum.Parse(typeof(TypeStateProvince), ConfigurationManager.AppSettings["MerchStateProvince"]);
            merchProfile.MerchantData.Address.PostalCode = ConfigurationManager.AppSettings["MerchPostalCode"];
            merchProfile.MerchantData.Address.CountryCode = (TypeISOCountryCodeA3)Enum.Parse(typeof(TypeISOCountryCodeA3), ConfigurationManager.AppSettings["MerchCountryCode"]);

            merchProfile.TransactionData = new MerchantProfileTransactionData();
            merchProfile.TransactionData.BankcardTransactionDataDefaults = new BankcardTransactionDataDefaults();
            merchProfile.TransactionData.BankcardTransactionDataDefaults.CurrencyCode = (TypeISOCurrencyCodeA3)Enum.Parse(typeof(TypeISOCurrencyCodeA3), ConfigurationManager.AppSettings["CurrencyCode"]);
            merchProfile.TransactionData.BankcardTransactionDataDefaults.CustomerPresent =(CustomerPresent)Enum.Parse(typeof (CustomerPresent), ConfigurationManager.AppSettings["CustomerPresent"]);
            merchProfile.TransactionData.BankcardTransactionDataDefaults.RequestACI = (RequestACI) Enum.Parse(typeof (RequestACI), ConfigurationManager.AppSettings["RequestACI"]);
            merchProfile.TransactionData.BankcardTransactionDataDefaults.EntryMode = (EntryMode) Enum.Parse(typeof (EntryMode), ConfigurationManager.AppSettings["TxnData_EntryMode"]);
            merchProfile.TransactionData.BankcardTransactionDataDefaults.RequestAdvice = RequestAdvice.NotCapable; // [NotSet,NotCapable,Capable]

            var merchProfiles = new List<MerchantProfile>();
            merchProfiles.Add(merchProfile);
            return merchProfiles;
        }
        private void GetMerchantProfile()
        {
            if (Helper.MerchantProfileId.Length < 1)
            {
                MessageBox.Show("Please select a merchant profileId");
                return;
            }

            Helper.CheckTokenExpire();
            string _strServiceID = Helper.ServiceID;
            string _strSessionToken = Helper.SessionToken;

            merchantProfile =
                Helper.Cwssic.GetMerchantProfile(_strSessionToken, Helper.MerchantProfileId, _strServiceID, TenderType.Credit);
        }
        public List<MerchantProfile> GetMerchantProfiles(string sessionToken, string serviceId, TenderType tenderType, string merchantProfileId = null)
        {
            if (_msgFormat == MessageFormat.SOAP.ToString())
            {
                using (var client = new CWSServiceInformationClient(ConfigurationManager.AppSettings["Bindings.StsSoap"]))
                {
                    try
                    {
                        return client.GetMerchantProfiles(sessionToken, serviceId, tenderType).ToList();
                    }
                    catch (FaultException ex)
                    {
                        SoapFaultHandler.HandleFaultException(ex);
                    }
                }
            }
            else // REST JSON or XML
            {
                var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());

                // For REST, to return all Merchant Profiles by merchantProfileId. Otherwise return all Merchant Profiles by service ID.
                var requestString = "";
                if(!string.IsNullOrEmpty(merchantProfileId))
                    requestString = RestBaseUri + "/merchProfile?merchantProfileId=" + merchantProfileId;
                else
                    requestString = RestBaseUri + "/merchProfile?serviceId=" + serviceId;

                HttpWebRequest request = WebRequest.Create(requestString) as HttpWebRequest;
                request.Method = HttpMethod.GET.ToString();
                request.Credentials = new NetworkCredential(sessionToken, "");

                request.ContentType = isJson ? "application/json" : "application/xml";
                // You'll need to use the Rest merchant profile Id Data Contract for serializing. This is then converted to use the standard data contract.
                var restMerchProfiles = new List<MerchantProfileId>();
                try
                {
                    restMerchProfiles = RestHelper.GetResponseList<MerchantProfileId>(request, isJson);
                }
                catch (Exception ex)
                {
                    RestFaultHandler.HandleFaultException(ex, isJson);
                }

                var merchProfiles = new List<MerchantProfile>();
                foreach (var rmp in restMerchProfiles)
                {
                    var mp = new MerchantProfile();
                    mp.ProfileId = rmp.id;
                    mp.ServiceId = rmp.href.Split('=')[1];
                    merchProfiles.Add(mp);
                }
                return merchProfiles;
            }
            return null;
        }
        public MerchantProfile CreateMerchantProfile()
        {
            MerchantProfile merchData = new MerchantProfile();

            merchData.LastUpdated = DateTime.UtcNow;
            //MerchantData : http://www.evosnap.com/support/knowledgebase/service-information-data-elements/#merchantprofilemerchantdata
            merchData.MerchantData = new MerchantProfileMerchantData();
            //Address
            merchData.MerchantData.Address = new SampleCode.CWSServiceInformation.AddressInfo();
            merchData.MerchantData.Address.City = "Denver";
            merchData.MerchantData.Address.CountryCode = SampleCode.CWSServiceInformation.TypeISOCountryCodeA3.USA;
            merchData.MerchantData.Address.PostalCode = "80202";
            merchData.MerchantData.Address.StateProvince = SampleCode.CWSServiceInformation.TypeStateProvince.CA;
            merchData.MerchantData.Address.Street1 = "1553 Platte Street";
            merchData.MerchantData.Address.Street2 = "Suite #310";
            merchData.MerchantData.CustomerServiceInternet = "*****@*****.**";
            merchData.MerchantData.CustomerServicePhone = "303 5553232";
            merchData.MerchantData.Language = TypeISOLanguageCodeA3.ENG;
            merchData.MerchantData.MerchantId = "123456789012";
            merchData.MerchantData.Name = "Acme Widgets";
            merchData.MerchantData.Phone = "720 8881212";
            merchData.MerchantData.TaxId = "";

            //BankcardMerchantData : http://www.evosnap.com/support/knowledgebase/service-information-data-elements/#bankcardmerchantdata
            merchData.MerchantData.BankcardMerchantData = new BankcardMerchantData();
            merchData.MerchantData.BankcardMerchantData.ABANumber = "987654321";
            merchData.MerchantData.BankcardMerchantData.AcquirerBIN = "654321";
            merchData.MerchantData.BankcardMerchantData.AgentBank = "123456";
            merchData.MerchantData.BankcardMerchantData.AgentChain = "645231";
            merchData.MerchantData.BankcardMerchantData.Aggregator = false;
            merchData.MerchantData.BankcardMerchantData.ClientNumber = "1234";
            merchData.MerchantData.BankcardMerchantData.IndustryType = _ITV._IndustryType;
            merchData.MerchantData.BankcardMerchantData.Location = "12345";
            merchData.MerchantData.BankcardMerchantData.MerchantType = "";
            merchData.MerchantData.BankcardMerchantData.PrintCustomerServicePhone = false;
            merchData.MerchantData.BankcardMerchantData.QualificationCodes = "";
            merchData.MerchantData.BankcardMerchantData.ReimbursementAttribute = "A";
            merchData.MerchantData.BankcardMerchantData.SIC = "5999";
            merchData.MerchantData.BankcardMerchantData.SecondaryTerminalId = "12345678";
            merchData.MerchantData.BankcardMerchantData.SettlementAgent = "12AB";
            merchData.MerchantData.BankcardMerchantData.SharingGroup = "123ABC";
            merchData.MerchantData.BankcardMerchantData.StoreId = "1234";
            merchData.MerchantData.BankcardMerchantData.TerminalId = "98765432160550";
            merchData.MerchantData.BankcardMerchantData.TimeZoneDifferential = "005";
            //ElectronicCheckingMerchantData : http://www.evosnap.com/support/knowledgebase/service-information-data-elements/#electroniccheckingmerchantdata
            merchData.MerchantData.ElectronicCheckingMerchantData = new ElectronicCheckingMerchantData();
            merchData.MerchantData.ElectronicCheckingMerchantData.OrginatorId = "";
            merchData.MerchantData.ElectronicCheckingMerchantData.ProductId = "";
            merchData.MerchantData.ElectronicCheckingMerchantData.SiteId = "";
            //StoredValueMerchantData : http://www.evosnap.com/support/knowledgebase/service-information-data-elements/#storedvaluemerchantdata
            merchData.MerchantData.StoredValueMerchantData = new StoredValueMerchantData();
            merchData.MerchantData.StoredValueMerchantData.AgentChain = "";
            merchData.MerchantData.StoredValueMerchantData.ClientNumber = "";
            merchData.MerchantData.StoredValueMerchantData.IndustryType = _ITV._IndustryType;
            merchData.MerchantData.StoredValueMerchantData.SIC = "";
            merchData.MerchantData.StoredValueMerchantData.StoreId = "";
            merchData.MerchantData.StoredValueMerchantData.TerminalId = "";

            //TransactionData
            merchData.TransactionData = new MerchantProfileTransactionData();
            merchData.TransactionData.BankcardTransactionDataDefaults = new BankcardTransactionDataDefaults();
            merchData.TransactionData.BankcardTransactionDataDefaults.CurrencyCode = SampleCode.CWSServiceInformation.TypeISOCurrencyCodeA3.USD;
            merchData.TransactionData.BankcardTransactionDataDefaults.CustomerPresent = _ITV._CustomerPresent;
            merchData.TransactionData.BankcardTransactionDataDefaults.EntryMode = _ITV._EntryMode;
            merchData.TransactionData.BankcardTransactionDataDefaults.RequestACI = _ITV._RequestACI;
            merchData.TransactionData.BankcardTransactionDataDefaults.RequestAdvice = SampleCode.CWSServiceInformation.RequestAdvice.Capable;

            return merchData;
        }