Exemple #1
0
        public async Task <IActionResult> GetSubscriptionPlanDetailById([FromRoute] string planId /*, [FromBody] GetSubscriptionPlanDetailByIdQuery query*/)
        {
            try
            {
                planId = "P-1GP34431BG4466351MBAOLLA";
                //query.Id = Id;

                //if (!ModelState.IsValid)
                if (String.IsNullOrEmpty(planId))
                {
                    return(base.BadRequest(ModelState));
                }

                var query = new GetSubscriptionPlanDetailByIdQuery()
                {
                    Id = planId
                };

                var result = await _mediator.Send <GetSubscriptionPlanDetailByIdQueryResult>(query);

                return(Ok(result));
            }

            ///
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public async Task <SubscriptionPlanDetailsByPlanIdModel> GetSubscriptionPlanDetailById(GetSubscriptionPlanDetailByIdQuery query)
        {
            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", BearerToken);

            var response = await _httpClient.GetAsync($"https://api-m.sandbox.paypal.com/v1/billing/plans/{query.Id}");

            var contentString = await response.Content.ReadAsStringAsync();

            var content = Newtonsoft.Json.JsonConvert.DeserializeObject <SubscriptionPlanDetailsByPlanIdModel>(contentString);

            //var result = await _httpClient.GetFromJsonAsync<SubscriptionPlanDetailsByPlanIdModel>($"https://api-m.sandbox.paypal.com/v1/billing/plans/{query.Id}");

            return(content);
            //return Ok();
        }