Example #1
0
 public DigitalLineItem(
     // inherited
     string title,
     double price,
     int quantityPurchased,
     string productId = null,
     string sku = null,
     string condition = null,
     bool? requiresShipping = null,
     string category = null,
     string subCategory = null,
     string brand = null,
     Seller seller = null,
     DeliveredToType? deliveredTo = null,
     DateTime? deliveredAt = null,
     
     // giftcard specific
     string senderName = null,
     string displayName = null,
     bool? photoUploaded = null,
     string photoUrl = null,
     string greetingPhotoUrl = null,
     string message = null,
     string greetingMessage = null,
     string cardType = null,
     string cardSubType = null,
     string senderEmail = null,
     Recipient recipient = null
     )
     : base(title: title, price: price, quantityPurchased: quantityPurchased, productId: productId, sku: sku,
         condition: condition,
         requiresShipping: requiresShipping, seller: seller, deliveredTo: deliveredTo, delivered_at: deliveredAt,
         category: category, subCategory: subCategory, brand: brand,
         productType: OrderElements.ProductType.Digital)
 {
     SenderName = senderName;
     DisplayName = displayName;
     PhotoUploaded = photoUploaded;
     PhotoUrl = photoUrl;
     GreetingPhotoUrl = greetingPhotoUrl;
     Message = message;
     GreetingMessage = greetingMessage;
     CardType = cardType;
     CardSubtype = cardSubType;
     SenderEmail = senderEmail;
     Recipient = recipient;
 }
        /// <summary>
        /// Generates a new order object
        /// Mind that some of the fields of the order (and it's sub-objects) are optional
        /// </summary>
        /// <param name="orderNum">The order number to put in the order object</param>
        /// <returns></returns>
        private static Order GenerateOrder(int orderNum)
        {
            var customerAddress = new BasicAddress(
                address1: "27 5th avenue",
                city: "Manhattan",
                country: "United States",
                countryCode: "US",
                phone: "5554321234",
                address2: "Appartment 5",
                zipCode: "54545"
                );

            // putting sample customer details
            var customer = new Customer(
                firstName: "John",
                lastName: "Doe",
                id: "405050606",
                ordersCount: 4,
                email: "*****@*****.**",
                verifiedEmail: true,
                createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
                notes: "No additional info",
                address: customerAddress);

            // putting sample billing details
            var billing = new AddressInformation(
                firstName: "Ben",
                lastName: "Rolling",
                address1: "27 5th avenue",
                city: "Manhattan", 
                country: "United States",
                countryCode: "US",
                phone: "5554321234", 
                address2: "Appartment 5",
                zipCode: "54545",
                province: "New York",
                provinceCode: "NY",
                company: "IBM",
                fullName: "Ben Philip Rolling");

            var shipping = new AddressInformation(
                firstName: "Luke",
                lastName: "Rolling",
                address1: "4 Bermingham street", 
                city: "Cherry Hill",
                country: "United States",
                countryCode: "US", 
                phone: "55546665", 
                provinceCode: "NJ", 
                province: "New Jersey");

            var payments = new CreditCardPaymentDetails(
                avsResultCode: "Y",
                cvvResultCode: "n",
                creditCardBin: "124580", 
                creditCardCompany: "Visa",
                creditCardNumber: "XXXX-XXXX-XXXX-4242");

            var noChargeAmount = new NoChargeDetails(
                refundId: "123444",
                amount: 20.5,
                currency: "GBP",
                reason: "giftcard"
                );

            var lines = new[]
            {
                new ShippingLine(price: 22.22,title: "Mail"),
                new ShippingLine(price: 2,title: "Ship",code: "A22F")
            };

            var recipientSocial = new SocialDetails(
                                                    network: "Facebook",
                                                    publicUsername: "******",
                                                    accountUrl: "http://www.facebook.com/john.smith");

            var recipient = new Recipient(
                email: "*****@*****.**",
                phone: "96522444221",
                social: recipientSocial);


            var items = new[]
            {
                new LineItem(title: "Bag",price: 55.44,quantityPurchased: 1,productId: 48484,sku: "1272727",deliveredTo: DeliveredToType.StorePickup, delivered_at:new DateTime(2016, 12, 8, 14, 12, 12, DateTimeKind.Local)),
                new LineItem(title: "Monster", price: 22.3, quantityPurchased: 3, seller: new Seller(customer: customer,correspondence: 1, priceNegotiated: true, startingPrice: 120)),
                // Events Tickets Industry 
                new LineItem(title: "Concert", 
                             price: 123, 
                             quantityPurchased: 1, 
                             category: "Singers", 
                             subCategory: "Rock", 
                             eventName: "Bon Jovy", 
                             eventSectionName: "Section", 
                             eventCountry: "USA", 
                             eventCountryCode: "US",
                             latitude: 0,
                             longitude: 0),
                // Digital Goods (giftcard) industry
                new LineItem(title: "Concert", 
                            price: 123, 
                            quantityPurchased: 1, 
                            sender_name: "John", 
                            display_name: "JohnJohn", 
                            photo_uploaded: true, 
                            photo_url: "http://my_pic_url", 
                            greeting_photo_url: "http://my_greeting_pic_url", 
                            message: "Happy Birthday",
                            greeting_message: "Happy Birthday from John",
                            card_type: "regular",
                            card_sub_type: "birthday",
                            sender_email: "*****@*****.**",
                            recipient: recipient),
            };

            var discountCodes = new[] { new DiscountCode(moneyDiscountSum: 7, code: "1") };

            DecisionDetails decisionDetails = new DecisionDetails(ExternalStatusType.Approved, DateTime.Now); // make sure to initialize DateTime with the correct timezone

            // This is an example for an order with charge free sums (e.g. gift card payment)
            var chargeFreePayments = new ChargeFreePaymentDetails(
                gateway: "giftcard",
                amount: 45);

            // This is an example for client details section
            var clientDetails = new ClientDetails(
                accept_language: "en-CA",   
                user_agent: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

            var order = new Order(
                merchantOrderId: orderNum.ToString(), 
                email: "*****@*****.**", 
                customer: customer, 
                paymentDetails: payments,
                billingAddress: billing,
                shippingAddress: shipping,
                lineItems: items,
                shippingLines: lines,
                gateway: "authorize_net",
                customerBrowserIp: "165.12.1.1",
                currency: "USD", 
                totalPrice: 100.60,
                createdAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
                updatedAt: DateTime.Now, // make sure to initialize DateTime with the correct timezone
                discountCodes: discountCodes,
                source: "web",
                noChargeDetails: noChargeAmount,
                decisionDetails: decisionDetails,
                vendorId: "2",
                vendorName: "domestic",
                additionalEmails: new [] {"*****@*****.**","*****@*****.**"},
                chargeFreePaymentDetails: chargeFreePayments,
                clientDetails: clientDetails,
                groupFounderOrderID: "2222"
                );

            return order;
        }
Example #3
0
        /// <summary>
        /// Creates a new LineItem
        /// </summary>
        /// <param name="title">A title describing the product </param>
        /// <param name="price">The product price in the currency matching the one used in the whole order and set in the "Currency" field</param>
        /// <param name="quantityPurchased">Quantity purchased of the item</param>
        /// <param name="productId">The Product ID number (optional)</param>
        /// <param name="sku">The stock keeping unit of the product (optional)</param>
        public LineItem(string title,
                        double price, 
                        int quantityPurchased,

                        //optional
                        int? productId = null, 
                        string sku = null, 
                        string condition = null,
                        bool? requiresShipping = null, 
                        Seller seller = null,
                        DeliveredToType? deliveredTo = null,

                        // These are for events tickets industry
                        string category = null,
                        string subCategory = null, 
                        string eventName = null, 
                        string eventSectionName = null, 
                        DateTimeOffset? eventDate = null, 
                        string eventCity = null,
                        string eventCountry = null,
                        string eventCountryCode = null,
                        float? latitude = null,
                        float? longitude = null,
            
                        // These are for digital goods (gift card) industry
                        string sender_name = null, 
                        string display_name = null, 
                        bool   photo_uploaded = false,
                        string photo_url = null,
                        string greeting_photo_url = null,
                        string message = null,
                        string greeting_message = null,
                        string card_type = null,
                        string card_sub_type = null,
                        DateTime? delivered_at = null,
                        string sender_email = null,
                        Recipient recipient = null)
        {
            
            Title = title;
            Price = price;
            QuantityPurchased = quantityPurchased;

            // optional
            ProductId = productId;
            Sku = sku;
            Condition = condition;
            RequiresShipping = requiresShipping;
            Seller = seller;
            DeliveredTo = deliveredTo;

            // Events Tickets Industry
            Category = category;
            SubCategory = subCategory;
            EventName = eventName;
            EventSectionName = eventSectionName;
            EventDate = eventDate;
            EventCountryCode = eventCountryCode;
            EventCity = eventCity;
            Latitude = latitude;
            Longitude = longitude;

            // Digital Goods (gift cards)
            SenderName = sender_name;
            DisplayName = display_name;
            PhotoUploaded = photo_uploaded;
            PhotoUrl = photo_url;
            GreetingPhotoUrl = greeting_photo_url;
            Message = message;
            GreetingMessage = greeting_message;
            CardType = card_type;
            CardSubtype = card_sub_type;
            DeliveredAt = delivered_at;
            SenderEmail = sender_email;

            // Recipient details 
            Recipient = recipient;
        }