Ejemplo n.º 1
0
        //POST: Ebay/OrderApiInitiateGuestCheckoutSession/{data}
        public ActionResult OrderApiInitiateGuestCheckoutSession(EbayOrderApiInitiateGuestCheckoutSessionModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };

            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid User" }));
            }

            AddressResultModel addressData = addressTable.SelectRecord(new SelectAddressModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            CheckoutSessionResponse response = OrderAPI.InitiateGuestCheckoutSession(data.orderId, customerResult, addressData);

            InsertCustomerOrderModel customerOrder = new InsertCustomerOrderModel()
            {
                CustomerUUID      = customerResult.CustomerUUID,
                CheckoutSessionID = response.checkoutSessionId,
                ExpirationDate    = response.expirationDate,
                ImageURL          = data.imageUrl,
                PurchasePrice     = response.pricingSummary.total.value,
                Title             = response.lineItems[0].title
            };

            NonQueryResultModel orderResult = customerOrderTable.InsertRecord(customerOrder);

            return(Json(response));
        }
Ejemplo n.º 2
0
        public ActionResult GetAddress(PreferenceGetAddressModel data)
        {
            SelectCustomerModel customerData = new SelectCustomerModel()
            {
                Email = data.email
            };
            CustomerResultModel customerResult = customerTable.SelectRecord(customerData);

            if (customerResult.CustomerUUID == null)
            {
                return(Json(new { result = "Fail", reason = "Invalid Customer" }));
            }

            AddressResultModel customerAddress = addressTable.SelectRecord(new SelectAddressModel()
            {
                CustomerUUID = customerResult.CustomerUUID
            });

            return(Json(new { result = customerAddress }));
        }