/// <summary> /// Gets the sub-merchant account info /// </summary> /// <param name="subMerchantId">The sub-merchant account id</param> /// <returns></returns> public Tuple <IndividualMerchantInfo, FundingMerchantInfo, BusinessMerchantInfo> GetSubMerchantInfo(String subMerchantId) { var merchantAccount = _gateway.MerchantAccount.Find(subMerchantId); if (merchantAccount != null) { IndividualMerchantInfo individual = null; if (merchantAccount.IndividualDetails != null) { individual = new IndividualMerchantInfo { DateOfBirth = DateTime.Parse(merchantAccount.IndividualDetails.DateOfBirth), Email = merchantAccount.IndividualDetails.Email, FirstName = merchantAccount.IndividualDetails.FirstName, LastName = merchantAccount.IndividualDetails.LastName, Locality = merchantAccount.IndividualDetails.Address?.Locality, Phone = merchantAccount.IndividualDetails.Phone, PostalCode = merchantAccount.IndividualDetails.Address?.PostalCode, Region = merchantAccount.IndividualDetails.Address?.Region, Ssn = merchantAccount.IndividualDetails.SsnLastFour, StreetAddress = merchantAccount.IndividualDetails.Address?.StreetAddress }; } FundingMerchantInfo funding = null; if (merchantAccount.FundingDetails != null) { funding = new FundingMerchantInfo { AccountNumber = merchantAccount.FundingDetails.AccountNumberLast4, Descriptor = merchantAccount.FundingDetails.Descriptor, Email = merchantAccount.FundingDetails.Email, FundingDestination = FundingDestination.BANK.ToString(), MobilePhone = merchantAccount.FundingDetails.MobilePhone, RoutingNumber = merchantAccount.FundingDetails.RoutingNumber }; } BusinessMerchantInfo businnes = null; if (merchantAccount.BusinessDetails != null) { businnes = new BusinessMerchantInfo { DbaName = merchantAccount.BusinessDetails.DbaName, LegalName = merchantAccount.BusinessDetails.LegalName, Locality = merchantAccount.BusinessDetails.Address?.Locality, PostalCode = merchantAccount.BusinessDetails.Address?.PostalCode, Region = merchantAccount.BusinessDetails.Address?.Region, StreetAddress = merchantAccount.BusinessDetails.Address?.StreetAddress, TaxId = merchantAccount.BusinessDetails.TaxId }; } return(new Tuple <IndividualMerchantInfo, FundingMerchantInfo, BusinessMerchantInfo>(individual, funding, businnes)); } return(null); }
/// <summary> /// Creates the sub-merchant account in Braintree /// </summary> /// <param name="individual">The individual merchant info</param> /// <param name="business">The business merchant info</param> /// <param name="funding">The funding merchant info</param> /// <param name="isTosAccepted">The TOS accepted flag</param> /// <param name="merchantAccountId">The existing merchant account Id</param> public CreateSubMerchantResponse CreateOrUpdateSubMerchant(IndividualMerchantInfo individual, BusinessMerchantInfo business, FundingMerchantInfo funding, Boolean isTosAccepted, String merchantAccountId = null) { var request = new MerchantAccountRequest(); request.Individual = new IndividualRequest { FirstName = individual.FirstName, LastName = individual.LastName, Email = individual.Email, Phone = individual.Phone, DateOfBirth = individual.DateOfBirth.ToString("yyyy-MM-dd"), Ssn = individual.Ssn, Address = new AddressRequest { StreetAddress = individual.StreetAddress, Locality = individual.Locality, Region = individual.Region, PostalCode = individual.PostalCode } }; if (business != null) { request.Business = new BusinessRequest { LegalName = business.LegalName, DbaName = business.DbaName, TaxId = business.TaxId, Address = new AddressRequest { StreetAddress = business.StreetAddress, Locality = business.Locality, Region = business.Region, PostalCode = business.PostalCode } }; } request.Funding = new FundingRequest { Descriptor = funding.Descriptor, Destination = FundingDestination.BANK, //TODO: check this logic Email = funding.Email, MobilePhone = funding.MobilePhone, AccountNumber = funding.AccountNumber, RoutingNumber = funding.RoutingNumber }; request.TosAccepted = isTosAccepted; request.MasterMerchantAccountId = _configurationProvider["BraintreeMerchantAccountId"]; var result = String.IsNullOrEmpty(merchantAccountId) ? _gateway.MerchantAccount.Create(request) : _gateway.MerchantAccount.Update(merchantAccountId, request); var response = new CreateSubMerchantResponse { IsSuccess = result.IsSuccess(), }; if (response.IsSuccess) { response.SubMerchantId = result.Target.Id; response.AccountStatus = result.Target.Status.ToString(); } else { response.Errors = CollectResponseErrors(result.Errors, result.Message); } return(response); }