Exemple #1
0
        public static bool AuthorizeOrder(int orderID)
        {
            Request _request = new Request();

            Order orderData = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderID, true);

            _request.CardNumber             = orderData.CreditInfo.CreditCardNumber;
            _request.CardType               = GetCCType(orderData.CreditInfo.CreditCardName);
            _request.CardCvv                = orderData.CreditInfo.CreditCardCSC;
            _request.CurrencyCode           = "$";
            _request.ExpireDate             = orderData.CreditInfo.CreditCardExpired;
            _request.Amount                 = (double)orderData.Total;
            _request.FirstName              = orderData.CustomerInfo.BillingAddress.FirstName;
            _request.LastName               = orderData.CustomerInfo.BillingAddress.LastName;
            _request.Address1               = orderData.CustomerInfo.BillingAddress.Address1;
            _request.Address2               = orderData.CustomerInfo.BillingAddress.Address2;
            _request.City                   = orderData.CustomerInfo.BillingAddress.City;
            _request.State                  = StateManager.GetStateName(orderData.CustomerInfo.BillingAddress.StateProvinceId);
            _request.Country                = CountryManager.CountryCode(orderData.CustomerInfo.BillingAddress.CountryId);
            _request.ZipCode                = orderData.CustomerInfo.BillingAddress.ZipPostalCode;
            _request.TransactionDescription = orderData.CustomerInfo.BillingAddress.FirstName + " " + orderData.CustomerInfo.BillingAddress.LastName;
            _request.CustomerID             = orderData.CustomerId.ToString();
            _request.InvoiceNumber          = orderData.OrderId.ToString();
            _request.IPAddress              = orderData.IpAddress;
            _request.Email                  = orderData.Email;

            //Make transaction request
            Response _response = TokenexProcessor.GetInstance().PerformAuthRequest(_request);

            //Save gateway transaction
            Dictionary <string, AttributeValue> orderAttributes = new Dictionary <string, AttributeValue>();

            orderAttributes.Add("AuthRequest", new CSBusiness.Attributes.AttributeValue(CSCore.Utils.CommonHelper.Encrypt(_response.GatewayRequestRaw)));
            orderAttributes.Add("AuthResponse", new CSBusiness.Attributes.AttributeValue(_response.GatewayResponseRaw));
            CSResolve.Resolve <IOrderService>().UpdateOrderAttributes(orderData.OrderId, orderAttributes, null);

            bool _returnValue = false;

            //Save results
            if (_response != null && _response.ResponseType != TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId,
                                                              (_response.TransactionID == null) ? string.Empty : _response.TransactionID,
                                                              (_response.AuthCode == null) ? string.Empty : _response.AuthCode, 7);

                _returnValue = false;
            }
            else if (_response != null && _response.ResponseType == TransactionResponseType.Approved)
            {
                CSResolve.Resolve <IOrderService>().SaveOrder(orderData.OrderId,
                                                              (_response.TransactionID == null) ? string.Empty : _response.TransactionID,
                                                              (_response.AuthCode == null) ? string.Empty : _response.AuthCode, 4);
                _returnValue = true;
            }
            UserSessions.InsertSessionEntry(null, _returnValue, (decimal)(_request.Amount), orderData.CustomerId, orderID);

            return(_returnValue);
        }
 public override void Session_Start(object sender, EventArgs e)
 {
     UserSessions.InsertSessionEntry(Context);
 }