Example #1
0
        public Dictionary <string, string> GetGateways()
        {
            Dictionary <string, string> getWayItems = new Dictionary <string, string>();
            var             fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                              <entity name='tc_gateway'>
                                <attribute name='tc_iata' />
                                <attribute name='tc_gatewaytype' /> 
                                <attribute name='tc_gatewayid' />
                              </entity>
                            </fetch>";
            FetchExpression exp      = new FetchExpression(fetchXml);
            var             records  = orgService.RetrieveMultiple(exp);

            if (records == null || records.Entities.Count == 0)
            {
                return(null);
            }
            foreach (var item in records.Entities)
            {
                var iata       = item[Attributes.Gateway.Iata].ToString();
                var typeValue  = item.GetAttributeValue <OptionSetValue>(Attributes.Gateway.GatewayType).Value;
                var typeString = GetGatewayType((int)typeValue);
                var gateWay    = new Models.Gateway {
                    Code = $"{iata}_{typeString}", Id = item.Id.ToString()
                };
                getWayItems.Add(gateWay.Code, gateWay.Id);
            }
            ;
            return(getWayItems);
        }
Example #2
0
        public virtual System.Web.Mvc.ActionResult BankGateway(float totalPrice, int totalCount)
        {
            System.Guid userId    = Infrastructure.Sessions.AuthenticatedUser.Id;
            var         varOrders = UnitOfWork.OrdersRepository.Get()
                                    .Include(p => p.Products)
                                    .Where(current => current.userId == userId)
                                    .Where(current => current.IsActive == true)
                                    .Where(current => current.Products.IsActive == true).ToList();



            System.Random oRandom = new System.Random();
            oRandom.Next(1093250, 10000000); // minimum = 0, maximum = 1000


            Models.PayOnline oPayOnline = new Models.PayOnline
            {
                Id        = new System.Guid(),
                userId    = Infrastructure.Sessions.AuthenticatedUser.Id,
                OrderNo   = totalCount.ToString(),
                ReceiptNo = oRandom.ToString(),
                Payment   = totalPrice
            };

            //var varCustomersProfile = UnitOfWork.CustomersProfileRepository.Get()
            //    .Include(u => u.User)
            //    .Where(current => current.UserId == userId).ToList();

            if (varOrders.Count > 0)
            {
                RSACryptoServiceProvider.UseMachineKeyStore = true;
                string merchantCode = "321008";              //کد پذيرنده  //
                string terminalCode = "325160";              //کد ترمينال //
                string amount       = totalPrice.ToString(); // مبلغ فاکتور //
                //BankGatewayRedirect();
                // :  آدرس سايتی که مشتری پس از انجام تراکنش بايد به آن فرستاده شود //
                string redirectAddress = "http://amad-co.ir/BankGateway.cshtml";
                string timeStamp       = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                string invoiceNumber   = "515";                                               // شماره فاکتور //
                string invoiceDate     = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //تاريخ فاکتور //
                string action          = "1003";                                              // براي درخوايت خريد : 1003
                // براي درخواست برگشت خريد : 1004
                System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
                string primarykey = "<RSAKeyValue><Modulus>vGNaMAZxRvUPDHqPLkqteTxwRBuc19PceD6W21IB4pSSmck4t32gwTJvudZJsEWiRIAw+rVYmxBQNJaloVPwf60SBpp3seCfopV0B+Lnmsm6wZLcuNNLEmRFKE0Zp5HH7jomLUgtAy53xZnqfXz6aLx0YsVbaWalHj8cJ6TH/0k=</Modulus><Exponent>AQAB</Exponent><P>7tthrumhDGrGINXlyW/bIPUWZFKZcrzbB1geLT9TlslizvuZll29CH6HuAPO8mDGdM4CKut/pmM2G7DnUJAnRQ==</P><Q>yeivbHYSb8tRcR2QCfa9gc98Gi/iB8KcuFb4O5y6kF/X3S3tDU5aSr1l2TUKWZMoRQs9GHoZcmeYpWbWwRdGNQ==</Q><DP>Pnu1OgRz1MO5wK0zx1YzhJOYn/XbnmA5C9rJShzeyPs1ld/LdcJfyPEQn9qfMFiQkc2yU3f3lJcveF72o+SR4Q==</DP><DQ>cE/dnOCE2ujnEZvXLqOwwI+QweRWv+hSUvwVsts4r+yQX/kW/qrR8Pcvu0YUzsTbxqQ8xOvOUeQsdf0hgmEW7Q==</DQ><InverseQ>pnrwkhSLvarhfGxTkqr2pkLJr6usPDVsu5qXw2imQqao87iEPalEJndnNqQ50uNY5bPJPBzDi96U6FwUsbmEuQ==</InverseQ><D>B0NrxlvZOwhW+WVlGj6ccm1kHrW51fbZknR6hVMKHSq0fePTB5Z7MwSEAXRDokPTcWfhe498yEdYVrUgObIhnMzLwxVdXw+PPWIRlcNHRBMtSe9mjOSP8d+hCzUmzHPeuCmKfjPr5iwTu8z9NfycTupezn9D2cr51p35nMbX0KE=</D></RSAKeyValue>";  //کليد خصوصي فروشنده//
                rsa.FromXmlString(primarykey);
                string data = "#" + merchantCode + "#" + terminalCode + "#"
                              + invoiceNumber + "#" + invoiceDate + "#" + amount + "#" + redirectAddress
                              + "#" + action + "#" + timeStamp + "#";
                byte[] signMain = rsa.SignData(System.Text.Encoding.UTF8.GetBytes(data), new
                                               System.Security.Cryptography.SHA1CryptoServiceProvider());
                string sign = System.Convert.ToBase64String(signMain);


                Models.Gateway getway = UnitOfWork.PayOnlineRepository.Gateway(invoiceNumber, invoiceDate, amount, terminalCode, merchantCode,
                                                                               redirectAddress, timeStamp, action, sign);
                return(View(getway));
            }
            return(View());
        }
Example #3
0
        public Models.Gateway Gateway(string invoiceNumber, string invoiceDate, string amount, string terminalCode, string merchantCode, string redirectAddress,
                                      string timeStamp, string action, string sign)
        {
            Models.Gateway oGateway = new Models.Gateway
            {
                invoiceNumber   = invoiceNumber,
                invoiceDate     = invoiceDate,
                amount          = amount,
                terminalCode    = terminalCode,
                merchantCode    = merchantCode,
                redirectAddress = redirectAddress,
                timeStamp       = timeStamp,
                action          = action,
                sign            = sign
            };

            return(oGateway);
        }