Exemple #1
0
        static void Main(string[] args)
        {
            //object creation for full body class

            FullBody FB = new FullBody();

            //get the values from users

            FB.GetValuesForFullBody();
            FB.GetValuesForMidLayer();
            FB.GetValuesForMainBoard();
            //print the values
            FB.Display();
        }
Exemple #2
0
        public async Task <IHttpActionResult> getPayPalRouteWithAmount(int amount)
        {
            if (APIToken.Equals("notValid"))
            {
                APIToken = await getToken();
            }
            if (amount == 0)
            {
                return(BadRequest());
            }
            else
            {
                HttpClient client = GetClient();
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + APIToken);
                FullBody body = new FullBody();
                body.intent         = "CAPTURE";
                body.purchase_units = new List <PurchaseUnit>();
                body.purchase_units.Add(new PurchaseUnit {
                    amount = new UnifiedModels.Amount {
                        currency_code = "USD", value = amount
                    }
                });
                body.application_context              = new ApplicationContext();
                body.application_context.brand_name   = "TiendaVirtual";
                body.application_context.landing_page = "NO_PREFERENCE";
                body.application_context.user_action  = "PAY_NOW";
                body.application_context.return_url   = "http://localhost:52112/Compra/Exitosa";
                body.application_context.cancel_url   = "http://localhost:52112/Compra/Fallida";
                var response = await client.PostAsync(PayPal_API_URL + Order_URL, new StringContent(JsonConvert.SerializeObject(body), System.Text.Encoding.UTF8, "application/json"));

                var validator = response.Content.ReadAsStringAsync().Result;
                var json      = (JObject)JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);
                if (tokenValidatorByJsonResponse(validator))
                {
                    return(Ok(searchForApproveURL(json)));
                }
                else
                {
                    APIToken = await getToken();

                    return(Ok(searchForApproveURL(json)));
                }
            }
        }