예제 #1
0
        public SaveResult Create(GatewayAccountViewModel model, int userId, string userName)
        {
            GatewayAccount account = new GatewayAccount();

            account.Id       = model.Id;
            account.Username = model.Username;
            account.Password = PasswordHasher.HashPassword(model.Password);

            account.PhoneCode        = "";
            account.Cellphone        = "";
            account.MerchantName     = "";
            account.Balance          = 0;
            account.Status           = GayewayAccountStatus.Active;
            account.CallbackUrl      = "";
            account.IsVerifiedEmail  = false;
            account.CountryId        = 0;
            account.Currency         = "";
            account.RegistrationDate = DateTime.UtcNow;
            account.SecretKey        = "";
            account.IsAllowPayment   = true;

            GatewayProfile profile = new GatewayProfile();

            profile.AccountId          = model.Id;
            profile.CompanyName        = model.CompanyName;
            profile.Cellphone          = "";
            profile.LicenseNo          = model.LicenseNo;
            profile.LastName           = model.LastName;
            profile.FirstName          = model.FirstName;
            profile.IdentityDocNo      = model.IdentityDocNo;
            profile.IdentityDocType    = model.IdentityDocType;
            profile.IdentityExpiryDate = DateTime.UtcNow;
            profile.Address1           = "";
            profile.City                 = "";
            profile.State                = "";
            profile.Postcode             = "";
            profile.Country              = 0;
            profile.FrontIdentityImage   = model.FrontIdentityImage;
            profile.BackIdentityImage    = model.BackIdentityImage;
            profile.HandHoldWithCard     = model.HandHoldWithCard;
            profile.BusinessLicenseImage = model.BusinessLicenseImage;

            // Create ActionLog
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = userId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(CryptocurrenciesBLL).FullName + ".Create";
            actionLog.Username   = userName;
            actionLog.LogContent = "Create GatewayAccount " + model.Id;
            ActionLogBLL ab = new ActionLogBLL();

            ab.Create(actionLog);

            FiiiPayEnterpriseDB.AccountsDb.Insert(account);
            FiiiPayEnterpriseDB.ProfilesDb.Insert(profile);
            return(new SaveResult(true));
        }
예제 #2
0
        public SaveResult Update(GatewayAccountViewModel model, int userId, string userName)
        {
            GatewayAccount account = FiiiPayEnterpriseDB.AccountsDb.GetById(model.Id);

            account.Id       = model.Id;
            account.Username = model.Username;
            if (!string.IsNullOrWhiteSpace(model.Password))
            {
                account.Password = PasswordHasher.HashPassword(model.Password);
            }

            GatewayProfile profile = FiiiPayEnterpriseDB.ProfilesDb.GetById(model.Id);

            profile.AccountId       = model.Id;
            profile.CompanyName     = model.CompanyName;
            profile.LicenseNo       = model.LicenseNo;
            profile.LastName        = model.LastName;
            profile.FirstName       = model.FirstName;
            profile.IdentityDocNo   = model.IdentityDocNo;
            profile.IdentityDocType = model.IdentityDocType;

            if (model.FrontIdentityImage != Guid.Empty)
            {
                profile.FrontIdentityImage = model.FrontIdentityImage;
            }
            if (model.BackIdentityImage != Guid.Empty)
            {
                profile.BackIdentityImage = model.BackIdentityImage;
            }
            if (model.HandHoldWithCard != Guid.Empty)
            {
                profile.HandHoldWithCard = model.HandHoldWithCard;
            }
            if (model.BusinessLicenseImage != Guid.Empty)
            {
                profile.BusinessLicenseImage = model.BusinessLicenseImage;
            }

            // Create ActionLog
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = userId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(CryptocurrenciesBLL).FullName + ".Update";
            actionLog.Username   = userName;
            actionLog.LogContent = "Update GatewayAccount " + model.Id;
            ActionLogBLL ab = new ActionLogBLL();

            ab.Create(actionLog);

            FiiiPayEnterpriseDB.AccountsDb.Update(account);
            FiiiPayEnterpriseDB.ProfilesDb.Update(profile);
            return(new SaveResult(true));
        }
예제 #3
0
 public static IGatewayProfile MapCustomerProfileToGatewayProfile(this AuthorizeNet.APICore.getCustomerProfileResponse response)
 {
     var result = new GatewayProfile();
     result.ProfileCustomerData = new CustomerData();
     result.ProfileCustomerData.Address = new AddressType();
     result.Id = response.profile.customerProfileId;
     result.ProfileCustomerData.EmailAddress = response.profile.email;
     result.ProfileCustomerData.CustomerDescription = response.profile.description;
     if (response.profile.paymentProfiles != null)
     {
         result.PaymentProfiles = new List<IGatewayPaymentProfile>();
         response.profile.paymentProfiles.ToList().ForEach(n =>
             {
                 var gatewayPaymentProfile = n.MapCustomerPaymentProfileMaskTypeToGatewayPaymentProfile();
                 result.PaymentProfiles.Add(gatewayPaymentProfile);
             });
     }
     return result;
 }
예제 #4
0
        /// <summary>
        /// The List Virtual network sites operation retrieves the virtual
        /// networks configured for the subscription.  (see
        /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157185.aspx
        /// for more information)
        /// </summary>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// The response structure for the Server List operation.
        /// </returns>
        public async Task <NetworkListResponse> ListAsync(CancellationToken cancellationToken)
        {
            // Validate

            // Tracing
            bool   shouldTrace  = CloudContext.Configuration.Tracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = Tracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                Tracing.Enter(invocationId, this, "ListAsync", tracingParameters);
            }

            // Construct URL
            string url = new Uri(this.Client.BaseUri, "/").ToString() + this.Client.Credentials.SubscriptionId + "/services/networking/virtualnetwork";

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("x-ms-version", "2013-11-01");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        Tracing.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        Tracing.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml);
                        if (shouldTrace)
                        {
                            Tracing.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    NetworkListResponse result = null;
                    // Deserialize Response
                    cancellationToken.ThrowIfCancellationRequested();
                    string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                    result = new NetworkListResponse();
                    XDocument responseDoc = XDocument.Parse(responseContent);

                    XElement virtualNetworkSitesSequenceElement = responseDoc.Element(XName.Get("VirtualNetworkSites", "http://schemas.microsoft.com/windowsazure"));
                    if (virtualNetworkSitesSequenceElement != null)
                    {
                        foreach (XElement virtualNetworkSitesElement in virtualNetworkSitesSequenceElement.Elements(XName.Get("VirtualNetworkSite", "http://schemas.microsoft.com/windowsazure")))
                        {
                            NetworkListResponse.VirtualNetworkSite virtualNetworkSiteInstance = new NetworkListResponse.VirtualNetworkSite();
                            result.VirtualNetworkSites.Add(virtualNetworkSiteInstance);

                            XElement nameElement = virtualNetworkSitesElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure"));
                            if (nameElement != null)
                            {
                                string nameInstance = nameElement.Value;
                                virtualNetworkSiteInstance.Name = nameInstance;
                            }

                            XElement labelElement = virtualNetworkSitesElement.Element(XName.Get("Label", "http://schemas.microsoft.com/windowsazure"));
                            if (labelElement != null)
                            {
                                string labelInstance = labelElement.Value;
                                virtualNetworkSiteInstance.Label = labelInstance;
                            }

                            XElement idElement = virtualNetworkSitesElement.Element(XName.Get("Id", "http://schemas.microsoft.com/windowsazure"));
                            if (idElement != null)
                            {
                                string idInstance = idElement.Value;
                                virtualNetworkSiteInstance.Id = idInstance;
                            }

                            XElement affinityGroupElement = virtualNetworkSitesElement.Element(XName.Get("AffinityGroup", "http://schemas.microsoft.com/windowsazure"));
                            if (affinityGroupElement != null)
                            {
                                string affinityGroupInstance = affinityGroupElement.Value;
                                virtualNetworkSiteInstance.AffinityGroup = affinityGroupInstance;
                            }

                            XElement stateElement = virtualNetworkSitesElement.Element(XName.Get("State", "http://schemas.microsoft.com/windowsazure"));
                            if (stateElement != null)
                            {
                                string stateInstance = stateElement.Value;
                                virtualNetworkSiteInstance.State = stateInstance;
                            }

                            XElement addressSpaceElement = virtualNetworkSitesElement.Element(XName.Get("AddressSpace", "http://schemas.microsoft.com/windowsazure"));
                            if (addressSpaceElement != null)
                            {
                                NetworkListResponse.AddressSpace addressSpaceInstance = new NetworkListResponse.AddressSpace();
                                virtualNetworkSiteInstance.AddressSpace = addressSpaceInstance;

                                XElement addressPrefixesSequenceElement = addressSpaceElement.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure"));
                                if (addressPrefixesSequenceElement != null)
                                {
                                    foreach (XElement addressPrefixesElement in addressPrefixesSequenceElement.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure")))
                                    {
                                        addressSpaceInstance.AddressPrefixes.Add(addressPrefixesElement.Value);
                                    }
                                }
                            }

                            XElement subnetsSequenceElement = virtualNetworkSitesElement.Element(XName.Get("Subnets", "http://schemas.microsoft.com/windowsazure"));
                            if (subnetsSequenceElement != null)
                            {
                                foreach (XElement subnetsElement in subnetsSequenceElement.Elements(XName.Get("Subnet", "http://schemas.microsoft.com/windowsazure")))
                                {
                                    NetworkListResponse.Subnet subnetInstance = new NetworkListResponse.Subnet();
                                    virtualNetworkSiteInstance.Subnets.Add(subnetInstance);

                                    XElement nameElement2 = subnetsElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure"));
                                    if (nameElement2 != null)
                                    {
                                        string nameInstance2 = nameElement2.Value;
                                        subnetInstance.Name = nameInstance2;
                                    }

                                    XElement addressPrefixElement = subnetsElement.Element(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure"));
                                    if (addressPrefixElement != null)
                                    {
                                        string addressPrefixInstance = addressPrefixElement.Value;
                                        subnetInstance.AddressPrefix = addressPrefixInstance;
                                    }
                                }
                            }

                            XElement dnsElement = virtualNetworkSitesElement.Element(XName.Get("Dns", "http://schemas.microsoft.com/windowsazure"));
                            if (dnsElement != null)
                            {
                                XElement dnsServersSequenceElement = dnsElement.Element(XName.Get("DnsServers", "http://schemas.microsoft.com/windowsazure"));
                                if (dnsServersSequenceElement != null)
                                {
                                    foreach (XElement dnsServersElement in dnsServersSequenceElement.Elements(XName.Get("DnsServer", "http://schemas.microsoft.com/windowsazure")))
                                    {
                                        NetworkListResponse.DnsServer dnsServerInstance = new NetworkListResponse.DnsServer();
                                        virtualNetworkSiteInstance.DnsServers.Add(dnsServerInstance);

                                        XElement nameElement3 = dnsServersElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure"));
                                        if (nameElement3 != null)
                                        {
                                            string nameInstance3 = nameElement3.Value;
                                            dnsServerInstance.Name = nameInstance3;
                                        }

                                        XElement addressElement = dnsServersElement.Element(XName.Get("Address", "http://schemas.microsoft.com/windowsazure"));
                                        if (addressElement != null)
                                        {
                                            string addressInstance = addressElement.Value;
                                            dnsServerInstance.Address = addressInstance;
                                        }
                                    }
                                }
                            }

                            XElement gatewayElement = virtualNetworkSitesElement.Element(XName.Get("Gateway", "http://schemas.microsoft.com/windowsazure"));
                            if (gatewayElement != null)
                            {
                                NetworkListResponse.Gateway gatewayInstance = new NetworkListResponse.Gateway();
                                virtualNetworkSiteInstance.Gateway = gatewayInstance;

                                XElement profileElement = gatewayElement.Element(XName.Get("Profile", "http://schemas.microsoft.com/windowsazure"));
                                if (profileElement != null)
                                {
                                    GatewayProfile profileInstance = (GatewayProfile)Enum.Parse(typeof(GatewayProfile), profileElement.Value, false);
                                    gatewayInstance.Profile = profileInstance;
                                }

                                XElement sitesSequenceElement = gatewayElement.Element(XName.Get("Sites", "http://schemas.microsoft.com/windowsazure"));
                                if (sitesSequenceElement != null)
                                {
                                    foreach (XElement sitesElement in sitesSequenceElement.Elements(XName.Get("LocalNetworkSite", "http://schemas.microsoft.com/windowsazure")))
                                    {
                                        NetworkListResponse.LocalNetworkSite localNetworkSiteInstance = new NetworkListResponse.LocalNetworkSite();
                                        gatewayInstance.Sites.Add(localNetworkSiteInstance);

                                        XElement nameElement4 = sitesElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure"));
                                        if (nameElement4 != null)
                                        {
                                            string nameInstance4 = nameElement4.Value;
                                            localNetworkSiteInstance.Name = nameInstance4;
                                        }

                                        XElement vpnGatewayAddressElement = sitesElement.Element(XName.Get("VpnGatewayAddress", "http://schemas.microsoft.com/windowsazure"));
                                        if (vpnGatewayAddressElement != null)
                                        {
                                            string vpnGatewayAddressInstance = vpnGatewayAddressElement.Value;
                                            localNetworkSiteInstance.VpnGatewayAddress = vpnGatewayAddressInstance;
                                        }

                                        XElement addressSpaceElement2 = sitesElement.Element(XName.Get("AddressSpace", "http://schemas.microsoft.com/windowsazure"));
                                        if (addressSpaceElement2 != null)
                                        {
                                            NetworkListResponse.AddressSpace addressSpaceInstance2 = new NetworkListResponse.AddressSpace();
                                            localNetworkSiteInstance.AddressSpace = addressSpaceInstance2;

                                            XElement addressPrefixesSequenceElement2 = addressSpaceElement2.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure"));
                                            if (addressPrefixesSequenceElement2 != null)
                                            {
                                                foreach (XElement addressPrefixesElement2 in addressPrefixesSequenceElement2.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure")))
                                                {
                                                    addressSpaceInstance2.AddressPrefixes.Add(addressPrefixesElement2.Value);
                                                }
                                            }
                                        }

                                        XElement connectionsSequenceElement = sitesElement.Element(XName.Get("Connections", "http://schemas.microsoft.com/windowsazure"));
                                        if (connectionsSequenceElement != null)
                                        {
                                            foreach (XElement connectionsElement in connectionsSequenceElement.Elements(XName.Get("Connection", "http://schemas.microsoft.com/windowsazure")))
                                            {
                                                NetworkListResponse.Connection connectionInstance = new NetworkListResponse.Connection();
                                                localNetworkSiteInstance.Connections.Add(connectionInstance);

                                                XElement typeElement = connectionsElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure"));
                                                if (typeElement != null)
                                                {
                                                    LocalNetworkConnectionType typeInstance = VirtualNetworkManagementClient.ParseLocalNetworkConnectionType(typeElement.Value);
                                                    connectionInstance.Type = typeInstance;
                                                }
                                            }
                                        }
                                    }
                                }

                                XElement vPNClientAddressPoolElement = gatewayElement.Element(XName.Get("VPNClientAddressPool", "http://schemas.microsoft.com/windowsazure"));
                                if (vPNClientAddressPoolElement != null)
                                {
                                    NetworkListResponse.VPNClientAddressPool vPNClientAddressPoolInstance = new NetworkListResponse.VPNClientAddressPool();
                                    gatewayInstance.VPNClientAddressPool = vPNClientAddressPoolInstance;

                                    XElement addressPrefixesSequenceElement3 = vPNClientAddressPoolElement.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure"));
                                    if (addressPrefixesSequenceElement3 != null)
                                    {
                                        foreach (XElement addressPrefixesElement3 in addressPrefixesSequenceElement3.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure")))
                                        {
                                            vPNClientAddressPoolInstance.AddressPrefixes.Add(addressPrefixesElement3.Value);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        Tracing.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
        public override IGatewayProfile GetOrCreateCustomerProfile(IPaymentData data)
        {

            IGatewayProfile result = new GatewayProfile();            
            AuthorizeNet.APICore.messagesType messages = null;
            var profileId = GatewayHelper.CreateCustomerProfile(data.Customer.EmailAddress, data.Customer.CustomerDescription, out messages);
            result = GatewayHelper.GetCustomerProfile(profileId).MapCustomerProfileToGatewayProfile();          
            data.Transaction.TransactionMessages.AddRange(GetTransactionMessage(messages, "createCustomerProfileRequest"));
            return result;

        }
        public override IGatewayProfile GetCustomerProfile(string id)
        {
            long profileId = long.Parse(id);
            IGatewayProfile result = new GatewayProfile();           
            var response = GatewayHelper.GetCustomerProfile(profileId);
            result = response.MapCustomerProfileToGatewayProfile();
            return result;

        }