コード例 #1
0
ファイル: HomeModule.cs プロジェクト: huurneman/Samples
 private static IssueStandardLicense GetIssueStandardLicense(SubmitNewChargeFromIpn chargeFromIpn)
 {
     var order = new IssueStandardLicense
                 {
                     UniqueOrderId = chargeFromIpn.ReferenceNumber.ToString(),
                     LicenseQuantity = chargeFromIpn.Quantity,
                     OrderDate = chargeFromIpn.TransactionDate,
                     UpgradeProtectionValidUntil = chargeFromIpn.UntilDate, //!?orderDate.AddYears(1).AddDays(-1),
                     PlimusProduct = string.Format("{0} - {1}", chargeFromIpn.ProductId, chargeFromIpn.ProductName),
                     LicenseType = chargeFromIpn.ProductName,
                     //!?ParticularProducts = ParseParticularProduct(),
                     PlimusContract = string.Format("{0} - {1}", chargeFromIpn.ContractId, chargeFromIpn.ContractName),
                     Total = chargeFromIpn.InvoiceAmountUsd,
                     Currency = "USD",
                     //!?PlimusOrderNumber =originalReference,
                     PlimusLinkForReceipt = chargeFromIpn.ShopperOrderUrl,
                     //!?Properties = ParseParticularProperties(),
                     Buyer = new Buyer
                             {
                                 CompanyName = chargeFromIpn.Company,
                                 Address1 = chargeFromIpn.Address1,
                                 Address2 = chargeFromIpn.Address2,
                                 City = chargeFromIpn.City,
                                 StateProvince = chargeFromIpn.State,
                                 ZipPostalCode = chargeFromIpn.ZipCode,
                                 Country = chargeFromIpn.Country,
                                 ContactFirstName = chargeFromIpn.FirstName,
                                 ContactLastName = chargeFromIpn.LastName,
                                 ContactEmail = chargeFromIpn.Email,
                                 ContactPhone = chargeFromIpn.MobilePhone, //!? there are a lots of phones
                                 IpAddress = chargeFromIpn.RemoteAddress
                             }
                 };
     return order;
 }
コード例 #2
0
ファイル: ChargeController.cs プロジェクト: huurneman/Samples
        // POST api/Charge
        public void Post([FromUri] SampleIpn ipn)
        {
            // parse the form and save the data
            var submitNewChargeFromIpnCommand = new SubmitNewChargeFromIpn { ProductId = ipn.ProductId, ProductName = ipn.ProductName, PostId = ipn.PostId };

            //post a command
            WebApiApplication.Bus.Send(submitNewChargeFromIpnCommand);
        }
コード例 #3
0
ファイル: HomeModule.cs プロジェクト: huurneman/Samples
        private SubmitNewChargeFromIpn GetChargeFromRequest(DynamicDictionary query)
        {
            var res = new SubmitNewChargeFromIpn();
            var type = res.GetType();

            foreach (var propertyName in query.Keys)
            {
                var pi = type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

                if (pi == null)
                {
                    continue;
                }

                switch (Type.GetTypeCode(pi.PropertyType))
                {
                    case TypeCode.String:
                        pi.SetValue(res, query[propertyName].Value);
                        break;

                    case TypeCode.Boolean:
                        pi.SetValue(res, query[propertyName].Value == "Y");
                        break;

                    case TypeCode.DateTime:
                        pi.SetValue(res, DateTime.ParseExact(query[propertyName].Value, "MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture));
                        break;

                    default:
                    {
                        //much complex type than String
                        var val = Activator.CreateInstance(pi.PropertyType);
                        MethodInfo mi = pi.PropertyType.GetMethod("Parse", new[] { typeof(string) });

                        if (mi != null)
                        {
                            val = mi.Invoke(null, new object[] { query[propertyName].Value });
                        }

                        pi.SetValue(res, val);
                    }
                        break;
                }
            }

            return res;
        }
コード例 #4
0
ファイル: HomeModule.cs プロジェクト: huurneman/Samples
 private void SendIssueStandardLicense(SubmitNewChargeFromIpn order)
 {
 }
コード例 #5
0
ファイル: HomeModule.cs プロジェクト: huurneman/Samples
        private void ProcessIpnMessage(SubmitNewChargeFromIpn chargeFromIpn)
        {
            // bus.send with nancy self hosting in NServiceBus.hos process....

            SendIssueStandardLicense(chargeFromIpn);

            var order = GetIssueStandardLicense(chargeFromIpn);

            //Test validation. Will be used in test to check if all required fields are filled
            order.IsValid();
        }