Beispiel #1
0
        public void SaveData()
        {
            ClientCartContext clientData = ClientOrderData;

            if (Page.IsValid)
            {
                //Set Customer Information
                Address billingAddress = new Address();
                billingAddress.FirstName       = CommonHelper.fixquotesAccents(txtFirstName.Text);
                billingAddress.LastName        = CommonHelper.fixquotesAccents(txtLastName.Text);
                billingAddress.Address1        = CommonHelper.fixquotesAccents(txtAddress1.Text);
                billingAddress.Address2        = CommonHelper.fixquotesAccents(txtAddress2.Text);
                billingAddress.City            = CommonHelper.fixquotesAccents(txtCity.Text);
                billingAddress.StateProvinceId = Convert.ToInt32(ddlState.SelectedValue);
                billingAddress.CountryId       = Convert.ToInt32(ddlCountry.SelectedValue);
                billingAddress.ZipPostalCode   = CommonHelper.fixquotesAccents(txtZipCode.Text);

                Customer CustData = new Customer();
                CustData.FirstName      = CommonHelper.fixquotesAccents(txtFirstName.Text);
                CustData.LastName       = CommonHelper.fixquotesAccents(txtLastName.Text);
                CustData.PhoneNumber    = txtPhoneNumber1.Text + txtPhoneNumber2.Text + txtPhoneNumber3.Text;
                CustData.Email          = CommonHelper.fixquotesAccents(txtEmail.Text);
                CustData.Username       = CommonHelper.fixquotesAccents(txtEmail.Text);
                CustData.BillingAddress = billingAddress;
                //CustData.ShippingAddress = billingAddress;

                if (!pnlShippingAddress.Visible)
                {
                    CustData.ShippingAddress = billingAddress;
                }
                else
                {
                    Address shippingAddress = new Address();
                    shippingAddress.FirstName       = CommonHelper.fixquotesAccents(txtShippingFirstName.Text);
                    shippingAddress.LastName        = CommonHelper.fixquotesAccents(txtShippingLastName.Text);
                    shippingAddress.Address1        = CommonHelper.fixquotesAccents(txtShippingAddress1.Text);
                    shippingAddress.Address2        = CommonHelper.fixquotesAccents(txtShippingAddress2.Text);
                    shippingAddress.City            = CommonHelper.fixquotesAccents(txtShippingCity.Text);
                    shippingAddress.StateProvinceId = Convert.ToInt32(ddlShippingState.SelectedValue);
                    shippingAddress.CountryId       = Convert.ToInt32(ddlShippingCountry.SelectedValue);
                    shippingAddress.ZipPostalCode   = CommonHelper.fixquotesAccents(txtShippingZipCode.Text);

                    CustData.ShippingAddress = shippingAddress;
                }


                PaymentInformation paymentDataInfo = new PaymentInformation();
                string             CardNumber      = txtCCNumber1.Text;
                paymentDataInfo.CreditCardNumber  = CommonHelper.Encrypt(CardNumber);
                paymentDataInfo.CreditCardType    = Convert.ToInt32(ddlCCType.SelectedValue);
                paymentDataInfo.CreditCardName    = ddlCCType.SelectedItem.Text;
                paymentDataInfo.CreditCardExpired = new DateTime(int.Parse(ddlExpYear.SelectedValue), int.Parse(ddlExpMonth.SelectedValue), 1);
                paymentDataInfo.CreditCardCSC     = txtCvv.Text;

                clientData.PaymentInfo = paymentDataInfo;

                ClientOrderData = clientData;


                //Set the Client Order objects
                ClientCartContext contextData = (ClientCartContext)Session["ClientOrderData"];
                contextData.CustomerInfo      = CustData;
                contextData.CartAbandonmentId = CSResolve.Resolve <ICustomerService>().InsertCartAbandonment(CustData, contextData);
                Session["ClientOrderData"]    = contextData;
            }
        }
Beispiel #2
0
        public ShipRequestModel PopulateRequestData(CustomSettings customSettings, AddRmaResult result, IUnitOfWork unitOfWork)
        {
            // UPS Security
            UsernameToken usernameToken = new UsernameToken();

            usernameToken.Username = customSettings.UPSSecurity_UserToken_Username;
            usernameToken.Password = customSettings.UPSSecurity_UserToken_Password;

            ServiceAccessToken serviceAccessToken = new ServiceAccessToken();

            serviceAccessToken.AccessLicenseNumber = customSettings.UPSSecurity_ServiceAccessToken_AccessLicenseNumber;

            UPSSecurity UPSSecurity = new UPSSecurity();

            UPSSecurity.UsernameToken      = usernameToken;
            UPSSecurity.ServiceAccessToken = serviceAccessToken;
            // UPS Security -END

            // Request Object
            TransactionReference transactionReference = new TransactionReference();

            transactionReference.CustomerContext = result.OrderHistory.ErpOrderNumber;

            Request request = new Request();

            request.RequestOption        = "nonvalidate";
            request.TransactionReference = transactionReference;
            // Request Object -END

            // Shipper Object
            Shipper shipper = new Shipper();

            shipper.Name          = string.IsNullOrEmpty(result.OrderHistory.STCompanyName) ? result.OrderHistory.BTCompanyName : result.OrderHistory.STCompanyName;
            shipper.ShipperNumber = customSettings.Shipper_ShipperNumber;

            Address shipToAddress = new Address();

            shipToAddress.AddressLine       = string.IsNullOrEmpty(result.OrderHistory.STAddress1) ? result.OrderHistory.BTAddress1 : result.OrderHistory.STAddress1;
            shipToAddress.City              = string.IsNullOrEmpty(result.OrderHistory.STCity) ? result.OrderHistory.BTCity : result.OrderHistory.STCity;
            shipToAddress.StateProvinceCode = GetStateCode(result.OrderHistory, unitOfWork);
            shipToAddress.PostalCode        = string.IsNullOrEmpty(result.OrderHistory.STPostalCode) ? result.OrderHistory.BTPostalCode : result.OrderHistory.STPostalCode;

            var country = result.OrderHistory.CustomerNumber.ElementAt(0) == '1' ? "US": "CA";

            shipToAddress.CountryCode = country;

            shipper.Address = shipToAddress;
            // Shipper Object - END

            // Website address same for both US and CA
            Ship shipTo = new Ship();

            shipTo.Name          = "Brasseler USA";
            shipTo.AttentionName = "RETURNS DEPT";

            Phone shipTophone = new Phone();

            shipTophone.Number = "9129258525";

            shipTo.Phone = shipTophone;

            Address websiteAddress = new Address();

            websiteAddress.AddressLine       = "1 Brasseler Blvd";
            websiteAddress.City              = "Savannah";
            websiteAddress.StateProvinceCode = "GA";
            websiteAddress.PostalCode        = "31419";
            websiteAddress.CountryCode       = "US";

            shipTo.Address = websiteAddress;
            // Website address same for both US and CA - END

            // Ship From Addresses
            Ship shipFrom = new Ship();

            shipFrom.Name = string.IsNullOrEmpty(result.OrderHistory.STCompanyName) ? result.OrderHistory.BTCompanyName : result.OrderHistory.STCompanyName;

            Phone shipFromphone = new Phone();

            shipFromphone.Number = "9129258525";

            shipFrom.Phone = shipFromphone;

            Address shipFromAddress = new Address();

            shipFromAddress.AddressLine       = string.IsNullOrEmpty(result.OrderHistory.STAddress1) ? result.OrderHistory.BTAddress1 : result.OrderHistory.STAddress1;
            shipFromAddress.City              = string.IsNullOrEmpty(result.OrderHistory.STCity) ? result.OrderHistory.BTCity : result.OrderHistory.STCity;
            shipFromAddress.StateProvinceCode = GetStateCode(result.OrderHistory, unitOfWork);
            shipFromAddress.PostalCode        = string.IsNullOrEmpty(result.OrderHistory.STPostalCode) ? result.OrderHistory.BTPostalCode : result.OrderHistory.STPostalCode;
            shipFromAddress.CountryCode       = country;

            shipFrom.Address = shipFromAddress;
            // Ship From Addresses - END

            // Payment Information
            BillShipper billShipper = new BillShipper();

            billShipper.AccountNumber = customSettings.PaymentInformation_ShipmentCharge_AccountNumber;

            ShipmentCharge shipmentCharge = new ShipmentCharge();

            shipmentCharge.Type        = "01";
            shipmentCharge.BillShipper = billShipper;

            PaymentInformation paymentInformation = new PaymentInformation();

            paymentInformation.ShipmentCharge = shipmentCharge;
            // Payment Information - END

            //  Service Object
            LabelImageFormat service = new LabelImageFormat();

            service.Code        = "03";
            service.Description = "Ground";
            //  Service Object - END

            // Return Service Object
            LabelImageFormat retrunService = new LabelImageFormat();

            retrunService.Code        = "9";
            retrunService.Description = "Print Return Label";
            // Return Service Object - END

            // Package Object
            Package package = new Package();

            List <ReferenceNumber> referenceNumber = new List <ReferenceNumber>();

            ReferenceNumber erpReferenceNumber = new ReferenceNumber();

            erpReferenceNumber.Code  = "01";
            erpReferenceNumber.Value = "Customer #: " + (string.IsNullOrEmpty(result.OrderHistory.CustomerSequence) ? result.OrderHistory.CustomerNumber : result.OrderHistory.CustomerSequence);
            referenceNumber.Add(erpReferenceNumber);

            ReferenceNumber invoiceRefNumber = new ReferenceNumber();

            invoiceRefNumber.Code  = "02";
            invoiceRefNumber.Value = "Invoice #: " + GetInvoiceNumber(result.OrderHistory.ErpOrderNumber, unitOfWork);
            referenceNumber.Add(invoiceRefNumber);

            LabelImageFormat packaging = new LabelImageFormat();

            packaging.Code        = "02";
            packaging.Description = "Description";

            LabelImageFormat unitOfMeasurement = new LabelImageFormat();

            unitOfMeasurement.Code        = "LBS";
            unitOfMeasurement.Description = "Pounds";

            PackageWeight packageWeight = new PackageWeight();

            packageWeight.UnitOfMeasurement = unitOfMeasurement;
            packageWeight.Weight            = "1";

            package.ReferenceNumber = referenceNumber;
            package.Description     = "Dental instruments/equipment";
            package.Packaging       = packaging;
            package.PackageWeight   = packageWeight;
            // Package Object - END

            // Shipment Object
            Shipment shipment = new Shipment();

            shipment.Description        = "Return Label";
            shipment.Shipper            = shipper;
            shipment.ShipTo             = shipTo;
            shipment.ShipFrom           = shipFrom;
            shipment.PaymentInformation = paymentInformation;
            shipment.Service            = service;
            shipment.ReturnService      = retrunService;
            shipment.Package            = package;
            // Shipment Object - END

            //  Label Specification
            LabelImageFormat labelImageFormat = new LabelImageFormat();

            labelImageFormat.Code        = "GIF";
            labelImageFormat.Description = "GIF";

            LabelSpecification labelSpecification = new LabelSpecification();

            labelSpecification.LabelImageFormat = labelImageFormat;
            labelSpecification.HttpUserAgent    = "Mozilla/4.5";
            //  Label Specification - END

            // Shipment Request
            ShipmentRequest shipmentRequest = new ShipmentRequest();

            shipmentRequest.Request            = request;
            shipmentRequest.Shipment           = shipment;
            shipmentRequest.LabelSpecification = labelSpecification;
            // Shipment Request - END

            //  RMA Model
            ShipRequestModel shipRequestModel = new ShipRequestModel();

            shipRequestModel.UPSSecurity     = UPSSecurity;
            shipRequestModel.ShipmentRequest = shipmentRequest;
            //  RMA Model - END
            return(shipRequestModel);
        }
        public string SamplePaymentsData()
        {
            // Create the Sample Data using Model Classes of Payments API
            Console.WriteLine("\n Using sample Payload of Payments");
            _logger.Trace("Using sample Payload of Payments");

            var clientReferenceInformation = new ClientReferenceInformation {
                code = "TC50171_3"
            };

            var processingInformation = new ProcessingInformation {
                commerceIndicator = "internet"
            };

            var subMerchant = new SubMerchant
            {
                cardAcceptorID     = "1234567890",
                country            = "US",
                phoneNumber        = "650-432-0000",
                address1           = "900 Metro Center",
                postalCode         = "94404-2775",
                locality           = "Foster Cit",
                name               = "Visa Inc",
                administrativeArea = "CA",
                region             = "PEN",
                email              = "*****@*****.**"
            };

            var aggregatorInformation = new AggregatorInformation
            {
                subMerchant  = subMerchant,
                name         = "V-Internatio",
                aggregatorID = "123456789"
            };

            var billTo = new BillTo
            {
                country            = "US",
                lastName           = "VDP",
                address2           = "Address 2",
                address1           = "201 S. Division St.",
                postalCode         = "48104-2201",
                locality           = "Ann Arbor",
                administrativeArea = "MI",
                firstName          = "RTS",
                phoneNumber        = "999999999",
                district           = "MI",
                buildingNumber     = "123",
                company            = "Visa",
                email = "*****@*****.**"
            };

            var amountDetails = new AmountDetails
            {
                totalAmount = "102.21",
                currency    = "USD"
            };

            var orderInformation = new OrderInformation
            {
                billTo        = billTo,
                amountDetails = amountDetails
            };

            var card = new Card
            {
                expirationYear  = "2031",
                number          = "5555555555554444",
                securityCode    = "123",
                expirationMonth = "12",
                type            = "002"
            };

            var paymentInformation = new PaymentInformation {
                card = card
            };

            var payments = new Payments
            {
                clientReferenceInformation = clientReferenceInformation,
                processingInformation      = processingInformation,
                aggregatorInformation      = aggregatorInformation,
                orderInformation           = orderInformation,
                paymentInformation         = paymentInformation
            };

            return(JsonConvert.SerializeObject(payments, Formatting.Indented));
        }
Beispiel #4
0
        public void SaveData()
        {
            ClientCartContext clientData = (ClientCartContext)Session["ClientOrderData"];

            // attribute save example
            //clientData.OrderAttributeValues = new Dictionary<string, CSBusiness.Attributes.AttributeValue>();
            //clientData.OrderAttributeValues.Add("ref_url", new CSBusiness.Attributes.AttributeValue("http://www.google.com"));

            if (clientData.OrderAttributeValues == null)
            {
                clientData.OrderAttributeValues = new Dictionary <string, CSBusiness.Attributes.AttributeValue>();
            }
            clientData.OrderAttributeValues.AddOrUpdateAttributeValue("CustomOrderId", new CSBusiness.Attributes.AttributeValue("CS" + CommonHelper.GetRandonOrderNumber(DateTime.Now)));
            //Recapture billing information if the user modified the information
            if (rId == 0)
            {
                if (cbBillingDifferent.Checked) //override if the user select yes button
                {
                    Address billingAddress = new Address();
                    billingAddress.FirstName       = CommonHelper.fixquotesAccents(txtFirstName.Text);
                    billingAddress.LastName        = CommonHelper.fixquotesAccents(txtLastName.Text);
                    billingAddress.Address1        = CommonHelper.fixquotesAccents(txtAddress1.Text);
                    billingAddress.Address2        = CommonHelper.fixquotesAccents(txtAddress2.Text);
                    billingAddress.City            = CommonHelper.fixquotesAccents(txtCity.Text);
                    billingAddress.StateProvinceId = Convert.ToInt32(ddlState.SelectedValue);
                    billingAddress.CountryId       = Convert.ToInt32(ddlCountry.SelectedValue);
                    billingAddress.ZipPostalCode   = txtZipCode.Text;

                    clientData.CustomerInfo.FirstName      = CommonHelper.fixquotesAccents(txtFirstName.Text);
                    clientData.CustomerInfo.LastName       = CommonHelper.fixquotesAccents(txtLastName.Text);
                    clientData.CustomerInfo.BillingAddress = billingAddress;
                }
            }

            SetBillingAddress();


            PaymentInformation paymentDataInfo = new PaymentInformation();
            string             CardNumber      = txtCCNumber.Text;

            paymentDataInfo.CreditCardNumber  = CommonHelper.Encrypt(CardNumber);
            paymentDataInfo.CreditCardType    = Convert.ToInt32(ddlCCType.SelectedValue);
            paymentDataInfo.CreditCardName    = ddlCCType.SelectedItem.Text;
            paymentDataInfo.CreditCardExpired = new DateTime(int.Parse(ddlExpYear.SelectedValue), int.Parse(ddlExpMonth.SelectedValue), 1);
            paymentDataInfo.CreditCardCSC     = txtCvv.Text;

            CartContext.PaymentInfo = paymentDataInfo;

            Session["ClientOrderData"] = clientData;


            ////// Prepaid Card OverLay //////

            int  cardNo    = Convert.ToInt32(CardNumber.Substring(0, 6));
            bool isPrepaid = CSWebBase.PrepaidCardDAL.IsPrepaidCard(cardNo);

            if (isPrepaid && OrderHelper.IsMainKit() && !OrderHelper.IsOnePay())
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "open_expire_soon();", true);
            }
            else
            {
                int orderId = 0;

                if (CSFactory.OrderProcessCheck() == (int)OrderProcessTypeEnum.InstantOrderProcess ||
                    CSFactory.OrderProcessCheck() == (int)OrderProcessTypeEnum.EnableReviewOrder ||
                    CSFactory.OrderProcessCheck() == (int)OrderProcessTypeEnum.EnableUpsellReviewOrder)
                {
                    //Save Order information before upsale process

                    if (rId == 1)
                    {
                        orderId = CSResolve.Resolve <IOrderService>().SaveOrder(clientData);
                    }
                    else
                    {
                        //update order with modified customer shipping and billing and credit card information
                        orderId = clientData.OrderId;
                        CSResolve.Resolve <IOrderService>().UpdateOrder(orderId, clientData);
                    }

                    if (orderId > 1)
                    {
                        clientData.OrderId         = orderId;
                        Session["ClientOrderData"] = clientData;

                        if (rId == 1)
                        {
                            Response.Redirect("PostSale.aspx");
                        }
                        else
                        {
                            Response.Redirect("CardDecline.aspx");
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public CreateOrder()
 {
     Id              = Guid.NewGuid();
     Payment         = new PaymentInformation();
     AssignVehicleId = string.Empty;
 }
Beispiel #6
0
 public void SavePaymentPaymentInformations(PaymentInformation objSaveDetailListModel)
 {
     InsuranceContext.PaymentInformations.Insert(objSaveDetailListModel);
 }
Beispiel #7
0
 public void UpdatePaymentInformation(PaymentInformation objSaveDetailListModel)
 {
     InsuranceContext.PaymentInformations.Update(objSaveDetailListModel);
 }
 public bool SaveNewPayment(PaymentInformation payInfo)
 {
     return(db.SaveNewPayment(payInfo));
 }
        public void SaveData()
        {
            ClientCartContext clientData = (ClientCartContext)Session["ClientOrderData"];

            // attribute save example
            //clientData.OrderAttributeValues = new Dictionary<string, CSBusiness.Attributes.AttributeValue>();
            //clientData.OrderAttributeValues.Add("ref_url", new CSBusiness.Attributes.AttributeValue("http://www.google.com"));
            if (clientData.OrderAttributeValues == null)
            {
                clientData.OrderAttributeValues = new Dictionary <string, CSBusiness.Attributes.AttributeValue>();
            }
            clientData.OrderAttributeValues.Add("CustomOrderId", new CSBusiness.Attributes.AttributeValue("CS" + CommonHelper.GetRandonOrderNumber(DateTime.Now)));
            clientData.OrderAttributeValues.Add("cartabandonmentid", new CSBusiness.Attributes.AttributeValue(clientData.CartAbandonmentId.ToString()));


            //Recapture billing information if the user modified the information
            if (rId == 0)
            {
                if (Convert.ToBoolean(!cbBillingDifferent.Checked)) //override if the user select yes button
                {
                    Address shippingAddress = new Address();
                    shippingAddress.FirstName       = CommonHelper.fixquotesAccents(txtShippingFirstName.Text);
                    shippingAddress.LastName        = CommonHelper.fixquotesAccents(txtShippingLastName.Text);
                    shippingAddress.Address1        = CommonHelper.fixquotesAccents(txtShippingAddress1.Text);
                    shippingAddress.Address2        = CommonHelper.fixquotesAccents(txtShippingAddress2.Text);
                    shippingAddress.City            = CommonHelper.fixquotesAccents(txtShippingCity.Text);
                    shippingAddress.StateProvinceId = Convert.ToInt32(ddlShippingState.SelectedValue);
                    shippingAddress.CountryId       = Convert.ToInt32(ddlShippingCountry.SelectedValue);
                    shippingAddress.ZipPostalCode   = txtShippingZipCode.Text;

                    clientData.CustomerInfo.FirstName       = CommonHelper.fixquotesAccents(txtShippingFirstName.Text);
                    clientData.CustomerInfo.LastName        = CommonHelper.fixquotesAccents(txtShippingLastName.Text);
                    clientData.CustomerInfo.ShippingAddress = shippingAddress;
                }
            }

            SetShippingAddress();

            clientData.CartInfo.CartItems.Clear();
            clientData.CartInfo.ShippingAddress = clientData.CustomerInfo.ShippingAddress;
            int pid  = 104;
            int pid2 = 0;

            if (clientData.CustomerInfo.ShippingAddress.CountryId == 46) // Canada
            {
                pid2 = 108;
            }
            else if (clientData.CustomerInfo.ShippingAddress.CountryId == 231) //US
            {
                if (clientData.CustomerInfo.ShippingAddress.StateProvinceId == 1 ||
                    clientData.CustomerInfo.ShippingAddress.StateProvinceId == 389 ||
                    clientData.CustomerInfo.ShippingAddress.StateProvinceId == 388 ||
                    clientData.CustomerInfo.ShippingAddress.StateProvinceId == 11 ||
                    clientData.CustomerInfo.ShippingAddress.StateProvinceId == 390)
                {
                    pid2 = 108;
                }
            }
            //int qId = 1;
            clientData.CartInfo.AddOrUpdate(pid, 1, true, false, false);
            clientData.CartInfo.AddOrUpdate(107, 1, false, false, false);
            if (pid2 > 0)
            {
                clientData.CartInfo.AddOrUpdate(pid2, 1, false, false, false);
            }
            clientData.CartInfo.Compute();
//            Response.Redirect(string.Format("AddProduct.aspx?PId={0}&CId={1}&QId={2}&DId={3}",
//pid, Convert.ToString((int)CSBusiness.ShoppingManagement.ShoppingCartType.SingleCheckout), ddlQuantityList.SelectedValue, 50));

            PaymentInformation paymentDataInfo = new PaymentInformation();
            string             CardNumber      = txtCCNumber.Text;

            paymentDataInfo.CreditCardNumber  = CommonHelper.Encrypt(CardNumber);
            paymentDataInfo.CreditCardType    = Convert.ToInt32(ddlCCType.SelectedValue);
            paymentDataInfo.CreditCardName    = ddlCCType.SelectedItem.Text;
            paymentDataInfo.CreditCardExpired = new DateTime(int.Parse(ddlExpYear.SelectedValue), int.Parse(ddlExpMonth.SelectedValue), 1);
            paymentDataInfo.CreditCardCSC     = txtCvv.Text;

            CartContext.PaymentInfo = paymentDataInfo;



            int orderId = 0;

            if (CSFactory.OrderProcessCheck() == (int)OrderProcessTypeEnum.InstantOrderProcess ||
                CSFactory.OrderProcessCheck() == (int)OrderProcessTypeEnum.EnableReviewOrder)
            {
                //Save Order information before upsale process

                if (rId == 1)
                {
                    orderId = CSResolve.Resolve <IOrderService>().SaveOrder(clientData);
                }
                else
                {
                    //update order with modified customer shipping and billing and credit card information
                    orderId = clientData.OrderId;
                    CSResolve.Resolve <IOrderService>().UpdateOrder(orderId, clientData);
                }

                if (orderId > 1)
                {
                    clientData.OrderId         = orderId;
                    Session["ClientOrderData"] = clientData;

                    if (rId == 1)
                    {
                        Response.Redirect("PostSale.aspx");
                    }
                    else
                    {
                        Response.Redirect("CardDecline.aspx");
                    }
                }
            }
        }
Beispiel #10
0
 public CreateOrder(IEnumerable <OrderLine> lines, PaymentInformation payment, ShippingInformation shipping)
 {
     Lines    = lines;
     Payment  = payment;
     Shipping = shipping;
 }
        public static int SavePaymentInfo(string distributorID, string locale, PaymentInformation paymentInfo)
        {
            if (string.IsNullOrEmpty(distributorID))
            {
                return(0);
            }

            if (paymentInfo.IsTemporary)
            {
                Trace.TraceWarning("Method: SavePaymentInfo Distributor:'{0}' Locate: '{1}'", distributorID, locale);
                var payments = getGetPaymentInfoFromCache(distributorID, locale);
                if (null == payments)
                {
                    payments = new PaymentInfoItemList();
                    savePaymentInfoToCache(getCacheKey(distributorID, locale), payments);
                }
                PaymentInformation existing = null;
                try
                {
                    existing = payments.Find(p => p.ID == paymentInfo.ID);
                }
                catch (Exception ex)
                {
                    ExceptionPolicy.HandleException(ex, ProviderPolicies.SYSTEM_EXCEPTION);
                }

                if (null != existing)
                {
                    payments.Remove(existing);
                }

                payments.Add(paymentInfo);

                return(0);
            }
            else
            {
                var proxy = ServiceClientProvider.GetOrderServiceProxy();
                try
                {
                    string country = (locale.Length > 2) ? locale.Substring(3) : locale;

                    if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                    {
                        var request = new InsertPaymentInfoRequest_V02();
                        request.PaymentInfo   = paymentInfo;
                        request.DistributorID = distributorID;
                        request.CountryCode   = country;
                        var response =
                            proxy.InsertPaymentInfo(new InsertPaymentInfoRequest1(request)).InsertPaymentInfoResult as InsertPaymentInfoResponse_V01;
                        if (response != null && response.Status == ServiceResponseStatusType.Success)
                        {
                            ReloadPaymentInfo(distributorID, locale);
                            return(response.ID);
                        }
                    }
                    else
                    {
                        var request = new InsertPaymentInfoRequest_V01();
                        request.PaymentInfo   = paymentInfo;
                        request.DistributorID = distributorID;
                        request.CountryCode   = country;
                        var response =
                            proxy.InsertPaymentInfo(new InsertPaymentInfoRequest1(request)).InsertPaymentInfoResult as InsertPaymentInfoResponse_V01;
                        if (response != null && response.Status == ServiceResponseStatusType.Success)
                        {
                            ReloadPaymentInfo(distributorID, locale);
                            return(response.ID);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebUtilities.LogServiceExceptionWithContext <ServiceProvider.OrderSvc.IOrderService>(ex, proxy);
                }
            }
            return(0);
        }
Beispiel #12
0
        private async Task <List <string> > GetPaymentsAsync(TileSizeOption tileSize,
                                                             PaymentInformation paymentInformation)
        {
            var acct = await crudService.ReadManyNoTracked <AccountViewModel>()
                       .ToListAsync()
            ;

            var allPayments = new List <PaymentViewModel>();
            var allPayment  = new List <LiveTilesPaymentInfo>();

            foreach (var item in acct)
            {
                allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                     .Where(x => x.ChargedAccountId == item.Id)
                                     .ToList());

                // We have to catch here, since otherwise an Exception is thrown when no payments are there.
                try
                {
                    allPayments.AddRange(crudService.ReadManyNoTracked <PaymentViewModel>()
                                         .Where(x => x.TargetAccountId == item.Id)
                                         .ToList());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            foreach (var item in allPayments)
            {
                if (item.IsRecurring)
                {
                    allPayment.AddRange(GetRecurrence(item));
                }
                else
                {
                    var tileInfo = new LiveTilesPaymentInfo
                    {
                        Chargeaccountname = item.ChargedAccount.Name,
                        Amount            = item.Amount,
                        Date = item.Date.Date,
                        Type = item.Type
                    };
                    allPayment.Add(tileInfo);
                }
            }

            List <LiveTilesPaymentInfo> payments;

            if (paymentInformation == PaymentInformation.Previous)
            {
                payments = allPayment.OrderByDescending(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date <= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }
            else
            {
                payments = allPayment.OrderBy(x => x.Date.Date)
                           .ThenBy(x => x.Date.Date >= DateTime.Today.Date)
                           .Take(NUMBER_OF_PAYMENTS)
                           .ToList();
            }

            var returnList = payments.Select(x => LiveTileHelper.GetTileText(tileSize, x)).ToList();

            for (var i = returnList.Count; i < NUMBER_OF_PAYMENTS - 1; i++)
            {
                returnList.Add(string.Empty);
            }

            allPayments.Clear();
            return(returnList);
        }
Beispiel #13
0
        public static void Parse(string path, IReplayVisitor visitor)
        {
            var haipai       = new Tile[13];
            var scores       = new int[4];
            var scoreChanges = new int[4];

            var playerCount    = 4;
            var activePlayerId = 0;

            var indexInBlock = 0;
            var block        = File.ReadAllBytes(path);
            var maxIndex     = block.Length;

#if DEBUG
            var log = new StringBuilder();
#endif

            while (maxIndex > indexInBlock)
            {
                var action = block[indexInBlock++];
                if (action == 255)
                {
                    visitor.End();
#if DEBUG
                    log.AppendLine("end bundle");
#endif
                    return;
                }
                if (action == 127)
                {
                    visitor.EndMatch();
#if DEBUG
                    log.AppendLine("end match");
#endif
                    continue;
                }

                switch (action)
                {
                case 0: // GO flags: 1 byte
                    var flags = (GameTypeFlag)block[indexInBlock++];
                    if (flags.HasFlag(GameTypeFlag.Sanma))
                    {
                        playerCount = 3;
                    }

                    visitor.GameType(flags);
#if DEBUG
                    log.AppendLine("go");
#endif
                    break;

                case 1: // INIT seed: 6 bytes, ten: playerCount*4 bytes, oya: 1 byte
                {
                    var roundWind     = TileType.FromTileTypeId(27 + block[indexInBlock++] / 4);
                    var honba         = block[indexInBlock++];
                    var riichiSticks  = block[indexInBlock++];
                    var dice0         = block[indexInBlock++];
                    var dice1         = block[indexInBlock++];
                    var doraIndicator = Tile.FromTileId(block[indexInBlock++]);

                    for (var i = 0; i < playerCount; i++)
                    {
                        scores[i]     = BitConverter.ToInt32(block, indexInBlock) * 100;
                        indexInBlock += 4;
                    }

                    activePlayerId = block[indexInBlock++];

                    visitor.Seed(roundWind, honba, riichiSticks, dice0, dice1, doraIndicator);
                    visitor.Scores(scores);
                    visitor.Oya(activePlayerId);
#if DEBUG
                    log.AppendLine("init");
#endif
                    break;
                }

                case 2: // INIT haipai 1 byte playerId, 13 bytes tileIds
                {
                    var playerId = block[indexInBlock++];
                    for (var i = 0; i < 13; i++)
                    {
                        haipai[i] = Tile.FromTileId(block[indexInBlock++]);
                    }

                    visitor.Haipai(playerId, haipai);
#if DEBUG
                    log.AppendLine("haipai");
#endif
                    break;
                }

                case 3: // Draw: 1 byte playerId, 1 byte tileId
                {
                    var tileId = block[indexInBlock++];
                    var tile   = Tile.FromTileId(tileId);
                    visitor.Draw(activePlayerId, tile);
#if DEBUG
                    log.AppendLine("draw");
#endif
                    break;
                }

                case 4: // Discard: 1 byte playerId, 1 byte tileId
                {
                    var tileId = block[indexInBlock++];
                    var tile   = Tile.FromTileId(tileId);
                    visitor.Discard(activePlayerId, tile);

                    activePlayerId = (activePlayerId + 1) % 4;
#if DEBUG
                    log.AppendLine("discard");
#endif
                    break;
                }

                case 5: // Tsumogiri: 1 byte playerId, 1 byte tileId
                {
                    var tileId = block[indexInBlock++];
                    var tile   = Tile.FromTileId(tileId);
                    visitor.Draw(activePlayerId, tile);
                    visitor.Discard(activePlayerId, tile);

                    activePlayerId = (activePlayerId + 1) % 4;

#if DEBUG
                    log.AppendLine("tsumogiri");
#endif
                    break;
                }

                case 6: //Chii: 1 byte who, 1 byte fromWho, 1 byte called tileId, 2 bytes tileIds from hand, 1 byte 0 (padding)
                {
                    var who        = block[indexInBlock++];
                    var fromWho    = block[indexInBlock++];
                    var calledTile = Tile.FromTileId(block[indexInBlock++]);
                    var handTile0  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile1  = Tile.FromTileId(block[indexInBlock++]);
                    indexInBlock++;

                    visitor.Chii(who, fromWho, calledTile, handTile0, handTile1);

#if DEBUG
                    Debug.Assert(activePlayerId == who);
                    log.AppendLine("chii");
#endif
                    break;
                }

                case 7: //Pon: 1 byte who, 1 byte fromWho, 1 byte called tileId, 2 bytes tileIds from hand, 1 byte 0 (padding)
                {
                    var who        = block[indexInBlock++];
                    var fromWho    = block[indexInBlock++];
                    var calledTile = Tile.FromTileId(block[indexInBlock++]);
                    var handTile0  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile1  = Tile.FromTileId(block[indexInBlock++]);
                    indexInBlock++;

                    visitor.Pon(who, fromWho, calledTile, handTile0, handTile1);
#if DEBUG
                    Debug.Assert(activePlayerId != who || (fromWho + 1) % 4 == activePlayerId);
                    log.AppendLine("pon");
#endif
                    activePlayerId = who;
                    break;
                }

                case 8: //Daiminkan: 1 byte who, 1 byte fromWho, 1 byte called tileId, 3 bytes tileIds from hand
                {
                    var who        = block[indexInBlock++];
                    var fromWho    = block[indexInBlock++];
                    var calledTile = Tile.FromTileId(block[indexInBlock++]);
                    var handTile0  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile1  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile2  = Tile.FromTileId(block[indexInBlock++]);

                    visitor.Daiminkan(who, fromWho, calledTile, handTile0, handTile1, handTile2);
#if DEBUG
                    Debug.Assert(activePlayerId != who || (fromWho + 1) % 4 == activePlayerId);
                    log.AppendLine("daiminkan");
#endif
                    activePlayerId = who;
                    break;
                }

                case 9: //Shouminkan: 1 byte who, 1 byte fromWho, 1 byte called tileId, 1 byte added tileId, 2 bytes tileIds from hand
                {
                    var who        = block[indexInBlock++];
                    var fromWho    = block[indexInBlock++];
                    var calledTile = Tile.FromTileId(block[indexInBlock++]);
                    var addedTile  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile0  = Tile.FromTileId(block[indexInBlock++]);
                    var handTile1  = Tile.FromTileId(block[indexInBlock++]);

                    visitor.Shouminkan(who, fromWho, calledTile, addedTile, handTile0, handTile1);

#if DEBUG
                    Debug.Assert(activePlayerId == who);
                    log.AppendLine("shouminkan");
#endif
                    break;
                }

                case 10: //Ankan: 1 byte who, 1 byte who (padding), 4 bytes tileIds from hand
                {
                    var who = block[indexInBlock++];
                    indexInBlock++;
                    var tileType = TileType.FromTileId(block[indexInBlock++]);
                    indexInBlock++;
                    indexInBlock++;
                    indexInBlock++;

                    visitor.Ankan(who, tileType);

#if DEBUG
                    Debug.Assert(activePlayerId == who);
                    log.AppendLine("ankan");
#endif
                    break;
                }

                case 11: //Nuki: 1 byte who, 1 byte who (padding), 1 byte tileId, 3 bytes 0 (padding)
                {
                    var who = block[indexInBlock++];
                    indexInBlock++;
                    var tile = Tile.FromTileId(block[indexInBlock++]);
                    indexInBlock++;
                    indexInBlock++;
                    indexInBlock++;
                    visitor.Nuki(who, tile);

#if DEBUG
                    Debug.Assert(activePlayerId == who);
                    log.AppendLine("nuki");
#endif
                    break;
                }

                case 12: //Ron
                case 13: //Tsumo
                {
                    var honba        = block[indexInBlock++];
                    var riichiSticks = block[indexInBlock++];

                    var haiLength = block[indexInBlock++];
                    indexInBlock += haiLength;

                    var meldCount = block[indexInBlock++];
                    var isOpen    = HasOpenMeld(block, indexInBlock, meldCount);
                    indexInBlock += meldCount * 7;

                    var machi = Tile.FromTileId(block[indexInBlock++]); // machi

                    var fu        = BitConverter.ToInt32(block, indexInBlock);
                    var score     = BitConverter.ToInt32(block, indexInBlock + 4);
                    var limitKind = BitConverter.ToInt32(block, indexInBlock + 8); // limit kind: 1 for mangan, ... 5 for yakuman
                    indexInBlock += 12;

                    var yakuLength = block[indexInBlock++];
                    var yakuOffset = indexInBlock;
                    indexInBlock += yakuLength;

                    var yakumanLength = block[indexInBlock++];
                    var yakumanOffset = indexInBlock;
                    indexInBlock += yakumanLength;

                    var yaku = ToYakuEnum(block, yakuOffset, yakuLength, yakumanOffset, yakumanLength, isOpen);

                    var doraHaiLength = block[indexInBlock++];
                    indexInBlock += doraHaiLength;

                    var doraHaiUraLength = block[indexInBlock++];
                    indexInBlock += doraHaiUraLength;

                    var who     = block[indexInBlock++];
                    var fromWho = block[indexInBlock++];
                    var paoWho  = block[indexInBlock++];

                    for (var i = 0; i < playerCount; i++)
                    {
                        scores[i]       = BitConverter.ToInt32(block, indexInBlock);
                        indexInBlock   += 4;
                        scoreChanges[i] = BitConverter.ToInt32(block, indexInBlock);
                        indexInBlock   += 4;
                    }

                    var payment = new PaymentInformation(fu, score, scoreChanges, yaku);

                    if (action == 12)
                    {
                        visitor.Ron(who, fromWho, payment);
#if DEBUG
                        Debug.Assert(activePlayerId != who || (fromWho + 1) % 4 == activePlayerId);
                        log.AppendLine("ron");
#endif
                    }
                    else
                    {
                        visitor.Tsumo(who, payment);
#if DEBUG
                        Debug.Assert(activePlayerId == who);
                        log.AppendLine("tsumo");
#endif
                    }

                    break;
                }

                case 14: //Ryuukyoku: 2 byte ba, 2*4*playerCount byte score, 1 byte ryuukyokuType, 4 byte tenpaiState
                {
                    var honba        = block[indexInBlock++];
                    var riichiSticks = block[indexInBlock++];

                    for (var i = 0; i < playerCount; i++)
                    {
                        scores[i]       = BitConverter.ToInt32(block, indexInBlock);
                        indexInBlock   += 4;
                        scoreChanges[i] = BitConverter.ToInt32(block, indexInBlock);
                        indexInBlock   += 4;
                    }

                    var ryuukyokuType = (RyuukyokuType)block[indexInBlock++];

                    indexInBlock += 4; // tenpai states

                    visitor.Ryuukyoku(ryuukyokuType, honba, riichiSticks, scores, scoreChanges);
#if DEBUG
                    log.AppendLine("ryuukyoku");
#endif
                    break;
                }

                case 15: //Dora: 1 byte tileId
                {
                    var tileId = block[indexInBlock++];
                    visitor.Dora(Tile.FromTileId(tileId));
#if DEBUG
                    log.AppendLine("dora");
#endif
                    break;
                }

                case 16: //CallRiichi: 1 byte who
                {
                    var who = block[indexInBlock++];
                    visitor.DeclareRiichi(who);

#if DEBUG
                    Debug.Assert(activePlayerId == who);
                    log.AppendLine("riichi");
#endif
                    break;
                }

                case 17: //PayRiichi: 1 byte who
                {
                    var who = block[indexInBlock++];
                    visitor.PayRiichi(who);

#if DEBUG
                    Debug.Assert(activePlayerId == (who + 1) % 4);
                    log.AppendLine("pay");
#endif
                    break;
                }

                default:
                {
                    throw new InvalidDataException("Have to handle each value to read away the data");
                }
                }
            }
        }
        /// <summary>
        /// ตัดบัตรเครดิต
        /// </summary>
        /// <param name="payment">ข้อมูลบัตรเครดิตที่ต้องการดำเนินการ</param>
        public PaymentResult ChargeCreditCard(PaymentInformation paymentInfo)
        {
            var tokenCredential = new OAuthTokenCredential(_appConfig.PaypalClientId, _appConfig.PaypalClientSecret, new Dictionary <string, string>());
            var accessToken     = tokenCredential.GetAccessToken();
            var config          = new Dictionary <string, string>();

            config.Add("mode", "sandbox"); // HACK: Paypal mode ('live' or 'sandbox')
            var apiContext = new APIContext
            {
                Config      = config,
                AccessToken = accessToken
            };

            // A transaction defines the contract of a payment - what is the payment for and who is fulfilling it.
            var transaction = new Transaction()
            {
                amount = new Amount()
                {
                    currency = "USD",
                    total    = paymentInfo.TotalPrice.ToString(),
                    details  = new Details()
                    {
                        shipping = "0",
                        subtotal = paymentInfo.TotalPrice.ToString(),
                        tax      = "0"
                    }
                },
                description = $"User { paymentInfo.UserProfileId } pay { paymentInfo.TotalPrice.ToString("C2") } for course { paymentInfo.PurchaseForCourseId }",
            };

            // A resource representing a Payer that funds a payment.
            var payer = new Payer()
            {
                payment_method      = "credit_card",
                funding_instruments = new List <FundingInstrument>()
                {
                    new FundingInstrument()
                    {
                        credit_card = new CreditCard()
                        {
                            billing_address = new Address()
                            {
                                city         = paymentInfo.City,
                                country_code = paymentInfo.Country,
                                line1        = paymentInfo.Address,
                                postal_code  = paymentInfo.PostalCode,
                                state        = paymentInfo.State
                            },
                            cvv2         = paymentInfo.CVV,
                            expire_month = paymentInfo.ExpiredMonth,
                            expire_year  = paymentInfo.ExpiredYear,
                            first_name   = paymentInfo.FirstName,
                            last_name    = paymentInfo.LastName,
                            number       = paymentInfo.CreditCardNumber,
                            type         = paymentInfo.CardType.ToLower()
                        }
                    }
                },
                payer_info = new PayerInfo {
                    email = paymentInfo.UserProfileId
                }
            };

            // A Payment resource; create one using the above types and intent as `sale` or `authorize`
            var payment = new PayPal.Api.Payment()
            {
                intent       = "sale",
                payer        = payer,
                transactions = new List <Transaction>()
                {
                    transaction
                }
            };

            // Create a payment using a valid APIContext
            var createdPayment = payment.Create(apiContext);
            var result         = PaymentResult.Unknow;

            return(Enum.TryParse <PaymentResult>(createdPayment.state, out result) ? result : PaymentResult.Unknow);
        }