示例#1
0
        /// <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,
                accountType: "Premium");

            // 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[] {
                new CreditCardPaymentDetails(
                    avsResultCode: "Y",
                    cvvResultCode: "n",
                    creditCardBin: "124580",
                    creditCardCompany: "Visa",
                    creditCardNumber: "XXXX-XXXX-XXXX-4242",
                    creditCardToken: "2233445566778899"
                    )
            };

            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), registryType: RegistryType.Wedding),
                new LineItem(title: "Monster", price: 22.3, quantityPurchased: 3,
                             seller: new Seller(customer: customer, correspondence: 1, priceNegotiated: true, startingPrice: 120)),
                // Events Tickets Product (aplicaible for event industry merchants)
                new EventTicketLineItem(
                    title: "Concert",
                    price: 123,
                    quantityPurchased: 1,
                    category: "Singers",
                    subCategory: "Rock",
                    eventName: "Bon Jovy",
                    eventSectionName: "Section",
                    eventCountry: "USA",
                    eventCountryCode: "US",
                    latitude: 0,
                    longitude: 0),
                // Giftcard Product (appliciable for giftcard industry merchants)
                new DigitalLineItem(
                    title: "Concert",
                    price: 123,
                    quantityPurchased: 1,
                    senderName: "John",
                    displayName: "JohnJohn",
                    photoUploaded: true,
                    photoUrl: "http://my_pic_url",
                    greetingPhotoUrl: "http://my_greeting_pic_url",
                    message: "Happy Birthday",
                    greetingMessage: "Happy Birthday from John",
                    cardType: "regular",
                    cardSubType: "birthday",
                    senderEmail: "*****@*****.**",
                    recipient: recipient),
                // Travel ticket product (appliciable for travel industry merchants)
                new TravelTicketLineItem(title: "Concert",
                                         price: 123,
                                         quantityPurchased: 1,
                                         departureCity: "ashdod",
                                         departureCountryCode: "IL",
                                         transportMethod: TransportMethodType.Plane),
                // Accommodation reservation product (appliciable for travel industry merchants)
                new AccommodationLineItem(
                    title: "Hotel Arcadia - Standard Room",
                    price: 476,
                    quantityPurchased: 1,
                    productId: "123",
                    city: "London",
                    countryCode: "GB",
                    rating: "5",
                    numberOfGuests: 2,
                    cancellationPolicy: "Not appliciable",
                    accommodationType: "Hotel"),
                // Ride Ticket Product
                new RideTicketLineItem(
                    title: "Ride to JFK airport",
                    price: 74,
                    quantityPurchased: 1,
                    pickupAddress: shipping,
                    dropoffAddress: billing,
                    pickupDate: new DateTime(2019, 8, 1, 12, 1, 1, DateTimeKind.Local),
                    pickupLatitude: 0,
                    pickupLongitude: 0,
                    dropoffLatitude: 1,
                    dropoffLongitude: 1,
                    routeIndex: 1,
                    legIndex: 1,
                    transportMethod: "Taxi",
                    priceBy: "fixed",
                    vehicleClass: "executive",
                    carrierName: "Best darn taxi company in the world!",
                    driverId: "15EGT701",
                    meetNGreet: "Whenever you meet me, please greet me.",
                    cancellationPolicy: "24 hours in advance",
                    authorizedPayments: 74
                    )
            };

            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 custom = new Custom(
                app_dom_id: "D2C"
                );

            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,
                custom: custom,
                groupFounderOrderID: "2222",
                submissionReason: "Manual Decision"
                );

            return(order);
        }
示例#2
0
 public OrderDecision(string merchantOrderId, DecisionDetails decision)
     : base(merchantOrderId)
 {
     Decision = decision;
 }
 public OrderDecision(int merchantOrderId, DecisionDetails decision, IPaymentDetails[] paymentDetails = null)
     : base(merchantOrderId)
 {
     this.Decision = decision;
 }
示例#4
0
 public OrderDecision(int merchantOrderId, DecisionDetails decision)
     : base(merchantOrderId)
 {
     this.Decision = decision;
 }
示例#5
0
文件: Order.cs 项目: aflopes/sdk_net
        /// <summary>
        /// Creates a new order
        /// </summary>
        /// <param name="merchantOrderId">The unique id of the order at the merchant systems</param>
        /// <param name="email">The email used for contact in the order</param>
        /// <param name="customer">The customer information</param>
        /// <param name="paymentDetails">The payment details</param>
        /// <param name="billingAddress">Billing address</param>
        /// <param name="shippingAddress">Shipping address</param>
        /// <param name="lineItems">An array of all products in the order</param>
        /// <param name="shippingLines">An array of all shipping details for the order</param>
        /// <param name="gateway">The payment gateway that was used</param>
        /// <param name="customerBrowserIp">The customer browser ip that was used for the order</param>
        /// <param name="currency">A three letter code (ISO 4217) for the currency used for the payment</param>
        /// <param name="totalPrice">The sum of all the prices of all the items in the order, taxes and discounts included</param>
        /// <param name="createdAt">The date and time when the order was created</param>
        /// <param name="updatedAt">The date and time when the order was last modified</param>
        /// <param name="passengers">Passengers included in the order - used for Travel industry merchants</param>
        /// <param name="discountCodes">An array of objects, each one containing information about an item in the order (optional)</param>
        /// <param name="totalDiscounts">The total amount of the discounts on the Order (optional)</param>
        /// <param name="cartToken">Unique identifier for a particular cart or session that is attached to a particular order. The same ID should be passed in the Beacon JS (optional)</param>
        /// <param name="totalPriceUsd">The price in USD (optional)</param>
        /// <param name="closedAt">The date and time when the order was closed. If the order was closed (optional)</param>
        /// <param name="financialStatus">The financial status of the order (could be paid/voided/refunded/partly_paid/etc.)</param>
        /// <param name="fulfillmentStatus">The fulfillment status of the order</param>
        /// <param name="source">The source of the order</param>
        /// <param name="noChargeDetails">No charge sums - including all payments made for this order in giftcards, cash, checks or other non chargebackable payment methods</param>
        /// <param name="clientDetails">Technical information regarding the customer's browsing session</param>
        /// <param name="chargeFreePaymentDetails">Payment sums made using non-chargebackable methods and should be omitted from the Chargeback gurantee sum and Riskified fee</param>
        /// <param name="submissionReason">The reason for submitting this order for review</param>
        /// <param name="custom">Custom data object</param>
        public Order(string merchantOrderId,
                     string email,
                     Customer customer,
                     AddressInformation billingAddress,
                     AddressInformation shippingAddress,
                     LineItem[] lineItems,
                     ShippingLine[] shippingLines,
                     string gateway,
                     string customerBrowserIp,
                     string currency,
                     double totalPrice,
                     DateTime?createdAt,
                     DateTime updatedAt,
                     Passenger[] passengers         = null,
                     IPaymentDetails paymentDetails = null,
                     DiscountCode[] discountCodes   = null,
                     double?totalDiscounts          = null,
                     string cartToken                = null,
                     double?totalPriceUsd            = null,
                     DateTime?closedAt               = null,
                     string financialStatus          = null,
                     string fulfillmentStatus        = null,
                     string source                   = null,
                     NoChargeDetails noChargeDetails = null,
                     string[] additionalEmails       = null,
                     string vendorId                 = null,
                     string vendorName               = null,
                     DecisionDetails decisionDetails = null,
                     ClientDetails clientDetails     = null,
                     ChargeFreePaymentDetails chargeFreePaymentDetails = null,
                     string groupFounderOrderID = null,
                     string referringSite       = null,
                     string note      = null,
                     string name      = null,
                     string orderType = null,
                     SubmissionReason?submissionReason = null,
                     Custom custom = null)
            : base(merchantOrderId)
        {
            LineItems         = lineItems;
            ShippingLines     = shippingLines;
            BillingAddress    = billingAddress;
            ShippingAddress   = shippingAddress;
            Customer          = customer;
            Email             = email;
            CustomerBrowserIp = customerBrowserIp;
            Currency          = currency;
            TotalPrice        = totalPrice;
            Gateway           = gateway;
            CreatedAt         = createdAt;
            UpdatedAt         = updatedAt;

            // optional fields
            Passengers               = passengers;
            PaymentDetails           = paymentDetails;
            DiscountCodes            = discountCodes;
            TotalPriceUsd            = totalPriceUsd;
            TotalDiscounts           = totalDiscounts;
            CartToken                = cartToken;
            ClosedAt                 = closedAt;
            FinancialStatus          = financialStatus;
            FulfillmentStatus        = fulfillmentStatus;
            Source                   = source;
            NoChargeAmount           = noChargeDetails;
            AdditionalEmails         = additionalEmails;
            VendorId                 = vendorId;
            VendorName               = vendorName;
            Decision                 = decisionDetails;
            ClientDetails            = clientDetails;
            Custom                   = custom;
            ChargeFreePaymentDetails = chargeFreePaymentDetails;
            Name             = name;
            ReferringSite    = referringSite;
            Note             = note;
            OrderType        = orderType;
            SubmissionReason = submissionReason;

            // This field is added for gift card group purchase
            GroupFounderOrderID = groupFounderOrderID;
        }