public async Task <ResponseGetPaymentPayPal> GetPaymentPayPalAsync(string uri, GetPaymentPayPal _objPaymentRequest) { ResponseGetPaymentPayPal objPaymentResponse; string s = JsonConvert.SerializeObject(_objPaymentRequest); HttpResponseMessage response = null; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); objPaymentResponse = JsonConvert.DeserializeObject <ResponseGetPaymentPayPal>(SucessResponse); return(objPaymentResponse); } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); objPaymentResponse = JsonConvert.DeserializeObject <ResponseGetPaymentPayPal>(ErrorResponse); return(objPaymentResponse); } } }
public async void MyNotificationSave_Click(object sender, EventArgs e) { await Navigation.PushPopupAsync(new LoadingPopPage()); try { FriendNotification friendNotification = new FriendNotification(); GetPaymentPayPal _request = new GetPaymentPayPal(); string _response; List <ProductList> _productList = new List <ProductList>(); ProductList _product = new ProductList(); Up uP = new Up(); _product.ProductID = 1; _product.Name = Settings.Name; _product.Description = Settings.BillingReminderName + "," + Settings.FrequencyName + "," + Settings.SetReminderName; _product.UnitPrice = Settings.PriceName; _product.SKU = "1"; _product.OrderQty = 1; _productList.Add(_product); _request.ProductList = _productList; uP.Cost = Settings.PriceName; uP.DeliveryMethodId = Settings.SetReminderId; uP.DurationId = Settings.FrequencyId; uP.SubscriptionTypeId = Settings.BillingReminderId; uP.UserId = Convert.ToInt32(Settings.UserID); _request.up = uP; _request.SiteURL = "null"; _request.InvoiceNumber = Guid.NewGuid().ToString(); _request.Currency = "USD"; _request.OrderDescription = Settings.UserID.ToString(); _request.ShippingFee = "0"; _request.Tax = "0"; _request.UserId = (Settings.UserID).ToString(); string s = JsonConvert.SerializeObject(_request); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/PayPal/GetPaymentPayPalURL_user"; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(SucessResponse); await Navigation.PopAllPopupAsync(); await Navigation.PushAsync(new PaymentGateway(_response)); //Settings.PriceName = _response.Response.pricefriendNotification //var res = _response.Price; //Settings.PriceName = res; //Cost.Text = "Total New Subscriptions: US $" + res; //return _response; } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(ErrorResponse); DependencyService.Get <IToast>().Show("Error Occured"); //return _response; //Settings.PriceName = _response.Response.price; } } } catch (Exception ex) { var msg = ex.Message; } }
public async void getPaymentGateway_Click(object sender, EventArgs e) { try { await Navigation.PushPopupAsync(new LoadingPopPage()); MyNotificationPage myNotification = new MyNotificationPage(); GetPaymentPayPal _request = new GetPaymentPayPal(); string _response; List <ProductList> _productList = new List <ProductList>(); NotificationFriend notificationFriendList = new NotificationFriend(); notificationFriendList = await getListofInvitedFrnd(); Up uP = new Up(); foreach (var item in notificationFriendList.Response.listofFriends) { if (item.PaymentDone == 0) { ProductList _product = new ProductList(); _product.ProductID = 1; _product.Name = item.FriendsName; _product.Description = item.DeliveryType + "," + item.TotalMonths + "," + item.SubcriptionType; _product.UnitPrice = item.Cost; _product.SKU = item.SKU; _product.OrderQty = 1; _productList.Add(_product); } } //_product.ProductID = 1; //_product.Name = Settings.FriendName; //_product.Description = Settings.DeliveryMethodName + "," + Settings.DurationName + "," + Settings.SubscriptionTypeName; //_product.UnitPrice = Settings.PriceName; //_product.SKU = "1"; //_product.OrderQty = 1; //_productList.Add(_product); _request.ProductList = _productList; uP.Cost = TotalCost; uP.DeliveryMethodId = Settings.DeliveryMethodId; uP.DurationId = Settings.DurationId; uP.SubscriptionTypeId = Settings.SubscriptionTypeId; uP.UserId = Convert.ToInt32(Settings.UserID); _request.up = uP; _request.SiteURL = "null"; _request.InvoiceNumber = Guid.NewGuid().ToString(); _request.Currency = "USD"; _request.OrderDescription = Settings.UserID.ToString(); _request.ShippingFee = "0"; _request.Tax = "0"; _request.PayerID = (Settings.UserID).ToString(); _request.PaymentID = "null"; _request.Count = 1; _request.UserId = (Settings.UserID).ToString(); _request.StartID = "null"; _request.StartIndex = 1; _request.StartTime = "null"; _request.EndTime = "null"; _request.StartDate = "null"; _request.PayeeEmail = Settings.Email; _request.PayeeID = (Settings.UserID).ToString(); _request.SortBy = "Ascending"; _request.SortOrder = "Albhabetical"; string s = JsonConvert.SerializeObject(_request); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/PayPal/GetPaymentPayPalURL"; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(SucessResponse); await Navigation.PopAllPopupAsync(); await Navigation.PushAsync(new PaymentGateway(_response)); //Settings.PriceName = _response.Response.price; //var res = _response.Price; //Settings.PriceName = res; //Cost.Text = "Total New Subscriptions: US $" + res; //return _response; } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(ErrorResponse); await Navigation.PopAllPopupAsync(); DependencyService.Get <IToast>().Show("Error"); //return _response; //Settings.PriceName = _response.Response.price; } } } catch (Exception ex) { var msg = ex.Message; } }