public async void UpdateFinancialAmount(object sender, EventArgs e) { try { if (groceryAmount.Text != "") { bool check = await DisplayAlert("Job Compilation", "Are you sure to complete this Job, Once you press 'Yes' then record will be updated into our datadase ", "Yes", "No"); if (check) { ApiCalling api = new ApiCalling(); Dictionary <string, object> userData = SharedUserData.getUserData; TrollyFinancialInfo ob = new TrollyFinancialInfo() { trolliId = obj.trolliId, baseGroceryAmount = Convert.ToDouble(groceryAmount.Text) }; api.UpdateTrolliFee(ob); api.SendNotificationWhenSBEnterAmount(Convert.ToString(userData["fullName"]), obj.clientNotificationId, obj.trolliId, obj.assigneeId); await Navigation.PushAsync(new RatingAndReviewForClient(ob.trolliId, obj.clientId)); } } else { await DisplayAlert("", "Enter Grocery Amount", "ok"); } }catch (Exception ex) { await DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); } }
public void SaveTrolly(Object sender, EventArgs e) { ApiCalling apiCall = new ApiCalling(); Dictionary <string, object> userData = ShareUserData.getUserData; string deliveryDateTime = ""; if (datePicker.IsVisible == true && timePicker.IsVisible == true) { DateTime dateOnly = datePicker.Date; //DateTime dateOnly = timePicker.Time; deliveryDateTime = dateOnly.ToString("dd/MM/yyyy") + " " + timePicker.Time.ToString(); } else { deliveryDateTime = currentDate.Text + " " + currentTime.Text; } TrollyCreation trolly = new TrollyCreation { createdDate = DateTime.Now.ToString("dd/MM/yyyy"), lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = "My Trolly", trollyDetail = getItemsInJson(), assigneeId = "1234", clientId = Convert.ToString(userData["simNumber"]), status = "pending", isScheduledDelivery = "true", deliveryDateTime = deliveryDateTime }; apiCall.trollyCreation(trolly); Navigation.PushAsync(new PaymentCardInfo()); }
public void ToggledHandler(object sender, ToggledEventArgs e) { try { Dictionary <string, object> userData = SharedUserData.getUserData; bool isOnlineSeeker = e.Value; if (globalValue) { string fullName = Convert.ToString(userData["fullName"]); string simNumber = Convert.ToString(userData["simNumber"]); IsJobOnlineSeeker bean = new IsJobOnlineSeeker { fullName = fullName, simNumber = simNumber, isJobSeeker = "false" }; ApiCalling callApi = new ApiCalling(); callApi.IsJobOnlineSeeker(bean); Application.Current.Properties["isOnlineJobSeeker"] = false; globalValue = false; // OneSignal.Current.SetSubscription(false); DisplayAlert("Notification Msg", "Notification Off", "Ok"); } else { string fullName = Convert.ToString(userData["fullName"]); string simNumber = Convert.ToString(userData["simNumber"]); IsJobOnlineSeeker bean = new IsJobOnlineSeeker { fullName = fullName, simNumber = simNumber, isJobSeeker = "true" }; ApiCalling callApi = new ApiCalling(); callApi.IsJobOnlineSeeker(bean); Application.Current.Properties["isOnlineJobSeeker"] = true; globalValue = true; // OneSignal.Current.SetSubscription(true); DisplayAlert("Notification Msg", "Notification On", "Ok"); } }catch (Exception ex) { DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); } }
public void saveTrollyFees() { try { TrollyFinancialInfo feeInfo = new TrollyFinancialInfo() { isConfirmed = "false", baseGroceryAmount = 0, serviceProviderFee = totalFees, trolliFeeAmount = 0, totalAmount = totalFees, trolliId = ScheduledTrolly.UUIDs }; ApiCalling api = new ApiCalling(); api.SaveTrolliFee(feeInfo); }catch (Exception ex) { DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); } }
public async void JobStatusHandler(object sender, EventArgs e) { try { bool connect = CrossConnectivity.Current.IsConnected; if (connect) { if (items.status == "Open") { bool check = await DisplayAlert("", "Are you sure to Cancel the Job", "Yes", "No"); if (check) { ApiCalling apiCall = new ApiCalling(); TrollyCreation trolly = new TrollyCreation { createdDate = items.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = items.trollyTitle, trollyDetail = items.trollyDetail, trolliId = items.trolliId, clientId = items.clientId,//Convert.ToString(userData["simNumber"]), status = "Cancelled by Client", deliveryDateTime = items.deliveryDateTime, assigneeId = " ", SBNotificationId = " ", clientNotificationId = items.clientNotificationId }; // status.Text = ""; StatusUpdate("Cancelled by Client"); statusButton.Text = "Re-Open Job"; items.status = "Cancelled by Client"; apiCall.TrollyCreation(trolly); OnAppearing(); } } else if (items.status == "Cancelled by Client" || items.status == "Cancelled by Smart Buyer") { bool check = await DisplayAlert("", "Are you sure to re-open the Job", "Yes", "Cancel"); if (check) { ApiCalling apiCall = new ApiCalling(); TrollyCreation trolly = new TrollyCreation { createdDate = items.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = items.trollyTitle, trollyDetail = items.trollyDetail, trolliId = items.trolliId, clientId = items.clientId,//Convert.ToString(userData["simNumber"]), status = "Open", deliveryDateTime = items.deliveryDateTime, assigneeId = " ", SBNotificationId = " ", clientNotificationId = items.clientNotificationId }; // status.Text = "Open"; StatusUpdate("Open"); statusButton.Text = "Cancel Job"; items.status = "Open"; apiCall.TrollyCreation(trolly); OnAppearing(); } } else if (items.status == "Assign") { bool check = await DisplayAlert("", "You are about to cancel this Trolli, while it is already assigned to someone. The $5 base fee and $5 as a penalty will still be charged. Are you sure you want to cancel?", "Yes", "No"); if (check) { chargePenalty(items.stripeChargeId); ApiCalling apiCall = new ApiCalling(); TrollyCreation trolly = new TrollyCreation { createdDate = items.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = items.trollyTitle, trollyDetail = items.trollyDetail, trolliId = items.trolliId, clientId = items.clientId,//Convert.ToString(userData["simNumber"]), status = "Cancelled by Client", deliveryDateTime = items.deliveryDateTime, assigneeId = " ", SBNotificationId = " ", clientNotificationId = items.clientNotificationId, stripeChargeId = " " }; // status.Text = "Cancelled by Client"; StatusUpdate("Cancelled by Client"); statusButton.Text = "Re-Open Job"; items.status = "Cancelled by Client"; apiCall.TrollyCreation(trolly); apiCall.SendNotificationToSB(items.SBNotificationId); await DisplayAlert("", "Your Trolli has been cancelled", "Ok"); } } } else { await DisplayAlert("Uh Oh!", "It seems like you are not connected to internet. Retry once your connections is back", "Exit"); // internetCheck.IsVisible = true; // RetryVariable.IsVisible = true; } } catch (Exception ex) { DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); //Exception Class } }
public async void CancelJobHandler(object sender, EventArgs e) { try { bool connect = CrossConnectivity.Current.IsConnected; var locator = CrossGeolocator.Current; if (connect) { if (!locator.IsGeolocationAvailable || !locator.IsGeolocationEnabled) { await DisplayAlert("", "Trolli app requires access to location services, in order to function properly. If you do not allow location access, some features may not work as expected.", "Ok"); } else { if (items.status == "Assign") { bool check = await DisplayAlert("", "Are you sure to Cancel the Job?", "Yes", "No"); if (check) { ApiCalling apiCall = new ApiCalling(); TrollyCreation trolly = new TrollyCreation { createdDate = items.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = items.trollyTitle, trollyDetail = items.trollyDetail, trolliId = items.trolliId, clientId = items.clientId,//Convert.ToString(userData["simNumber"]), status = "Open", deliveryDateTime = items.deliveryDateTime, assigneeId = " ", SBNotificationId = " ", clientNotificationId = items.clientNotificationId, stripeChargeId = items.stripeChargeId }; StatusUpdate("Cancelled by Shopper"); // statusButton.Text = "Re-Open Job"; items.status = "Cancelled by Shopper"; apiCall.TrollyCreation(trolly); apiCall.SendNotificationToClient(items.clientNotificationId); apiCall.SendNotificationWhenSBCancelled(items.trolliId, items.clientNotificationId, items.SBNotificationId); OnAppearing(); } } } } else { await DisplayAlert("Uh Oh!", "It seems like you are not connected to internet. Retry once your connections is back", "Exit"); // internetCheck.IsVisible = true; // RetryVariable.IsVisible = true; } } catch (Exception ex) { await DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); //Exception Class } }
public async void FindSmartBuyer(Object sender, EventArgs e) { try { // searchText.IsVisible = true; StripeConfiguration.SetApiKey("sk_test_Q5wSnyXL03yN0KpPaAMYttOb"); if (IsCardAvailable) { /* ChargeDestinationCreateOptions chargeDestination = new ChargeDestinationCreateOptions { * Account = "acct_1DWkSgB4PaSzuOZk", * Amount = 1000 * }; */ var charge = new ChargeCreateOptions { Amount = Convert.ToInt32(50 * 100), // In cents, not dollars, times by 100 to convert Currency = "aud", // or the currency you are dealing with CustomerId = Convert.ToString(userData["stripeCustomerId"]), Capture = false }; var services = new ChargeService(); var response = services.Create(charge); TrollyCreation trolly = new TrollyCreation() { createdDate = trollyCreation.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = trollyCreation.trollyTitle, trollyDetail = trollyCreation.trollyDetail, trolliId = trollyCreation.trolliId, clientId = trollyCreation.clientId, status = "Open", deliveryDateTime = trollyCreation.deliveryDateTime, assigneeId = " ", clientNotificationId = trollyCreation.clientNotificationId, SBNotificationId = " ", stripeChargeId = response.Id }; api.TrollyCreation(trolly); searchText.IsVisible = true; await Navigation.PushAsync(new FindSmartBuyer()); await DisplayAlert("", "Transaction Id: " + response.Id, "Ok"); } else { /* var options = new TransferCreateOptions * { * Amount = 400, * Currency = "aud", * Destination = "acct_1DWlL0LUUlibc6UD" * }; * * var service = new TransferService(); * Transfer Transfer = service.Create(options); * * //-------Get IP Address---------// * var MyIp = ""; * string uploadId = ""; * foreach (IPAddress adress in Dns.GetHostAddresses(Dns.GetHostName())) * { * MyIp = adress.ToString(); * break; * } * * //------Camera will Open User take the Picture Of Idenity Card-----------// * var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions * { * Directory = "Sample", * Name = "test.jpg", * PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small * * }); * * //-------Upload File in stripe and return the file Id -------------// * using (FileStream stream = System.IO.File.Open(file.Path, FileMode.Open)) * { * var fileService = new FileService(); * var fileCreateOptions = new FileCreateOptions * { * File = stream, * Purpose = "identity_document", * }; * Stripe.File upload = fileService.Create(fileCreateOptions); * uploadId = upload.Id; * } * * //------Set File.id-----/// * AccountVerificationOptions verifiy = new AccountVerificationOptions { DocumentId = uploadId, }; * * * * //--------Create User Account Legal Entity-----------// * AccountLegalEntityOptions legalEntity = new AccountLegalEntityOptions * { * FirstName = "Saeed", * LastName = "Ali", * Address = new AddressOptions { City = "Sydney", Country = "AU", PostalCode = "5106", Line1 = "Home", State = "Victoria" }, * Dob = new AccountDobOptions { Day = 12, Month = 09, Year = 1990 }, * Type = "individual", * Verification = verifiy, * PhoneNumber = "+6112345678" * }; * * //--------Create Payout Account-----------// * var options = new AccountCreateOptions * { * Email = "*****@*****.**", * Type = AccountType.Custom, * Country = "AU", * LegalEntity = legalEntity * }; * var services = new AccountService(); * Account account = services.Create(options); * * * //---------Create External Bank Account and return Token---------/// * TokenCreateOptions optionss = new TokenCreateOptions * { * BankAccount = new BankAccountOptions * { * Country = "AU", * AccountNumber = "000123456", * RoutingNumber = "110000", * Currency = "aud" * * } * }; * TokenService service = new TokenService(); * Token stripeToken = service.Create(optionss); * * * var externalOption = new ExternalAccountCreateOptions * { * ExternalAccountTokenId = stripeToken.Id, //pass the bank account creation token * }; * var externalAccount = new ExternalAccountService(); * var bankAccount = externalAccount.Create(account.Id, externalOption); //Bank Account Created * * // await DisplayAlert("", "" + account.Id, "Ok"); * //api.AcceptedStripeAgreement(account.Id,CurrentTimeMillis(), MyIp); //Accepted Stripe TOS * * * * * * */ /* * AccountTosAcceptanceOptions tos = new AccountTosAcceptanceOptions() * { * Ip = MyIp, * Date = DateTime.Now.AddMilliseconds(1234) * }; * DisplayAlert("", "" + DATE, "Ok"); * TokenCreateOptions optionss = new TokenCreateOptions * { * BankAccount = new BankAccountOptions * { * Country = "AU", * AccountNumber = "000123456", * RoutingNumber = "110000", * Currency = "aud" * * } * }; * TokenService service = new TokenService(); * Token stripeToken = service.Create(optionss); * * var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions * { * Directory = "Sample", * Name = "test.jpg", * PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small * * }); * * AccountVerificationOptions verifiy = new AccountVerificationOptions { DocumentId = file.Path, }; * * AccountLegalEntityOptions legalEntity = new AccountLegalEntityOptions * { * FirstName = "Usman", * LastName = "Kamran", * Address = new AddressOptions { City = "Sydney", Country = "AU", PostalCode = "5106", Line1 = "Home", State = "Victoria"}, * Dob = new AccountDobOptions { Day = 12, Month = 09, Year = 1990}, * Verification = verifiy, * Type = "individual", * * }; * var options = new AccountCreateOptions * { * Email = "*****@*****.**", * Type = AccountType.Custom, * Country = "AU", * LegalEntity =legalEntity * }; * * var services = new AccountService(); * Account account = services.Create(options); * DisplayAlert("", "" + account.TosAcceptance.Ip, "Ok"); * */ // DisplayAlert("", "" + tos.Date, "Ok"); string cardHolderNameVar = cardHolderName.Text; string cardNumberVar = cardNumber.Text; string experiationDateVar = experiationDate.Text; string cvvVar = cvcNumber.Text; TokenCreateOptions options = new TokenCreateOptions { Card = new CreditCardOptions { Number = cardNumberVar, ExpYear = 2019, ExpMonth = 11, Cvc = cvvVar, Name = cardHolderNameVar } }; TokenService service = new TokenService(); Token stripeToken = service.Create(options); var customerOptions = new CustomerCreateOptions { Email = Convert.ToString(userData["email"]), SourceToken = stripeToken.Id, }; var customerService = new CustomerService(); Customer customer = customerService.Create(customerOptions); var charge = new ChargeCreateOptions { Amount = Convert.ToInt32(50 * 100), // In cents, not dollars, times by 100 to convert Currency = "aud", // or the currency you are dealing with CustomerId = customer.Id, Capture = false }; var services = new ChargeService(); var response = services.Create(charge); await DisplayAlert("", "Transaction Id: " + response.Id, "Ok"); ApiCalling api = new ApiCalling(); api.CreateStripeCustomerId(Convert.ToString(userData["simNumber"]), customer.Id); // TrollyCreation trolly = new TrollyCreation() { createdDate = trollyCreation.createdDate, lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = trollyCreation.trollyTitle, trollyDetail = trollyCreation.trollyDetail, trolliId = trollyCreation.trolliId, clientId = trollyCreation.clientId, status = "Open", deliveryDateTime = trollyCreation.deliveryDateTime, assigneeId = " ", clientNotificationId = trollyCreation.clientNotificationId, SBNotificationId = " ", stripeChargeId = response.Id }; api.TrollyCreation(trolly); // DisplayAlert("", output, "OK"); // Application.Current.Properties["paymentCardInfo"] = output; searchText.IsVisible = true; await Navigation.PushAsync(new FindSmartBuyer()); } } catch (Exception ex) { await DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); } // Navigation.PushAsync(new FindSmartBuyer()); // DisplayAlert("", "" + name, "Ok"); // Charge the Customer instead of the card: /* var chargeOptions = new ChargeCaptureOptions * { * Amount = 50, * }; * var chargeService = new ChargeService(); * Charge charge = chargeService.Capture("ch_1DUTlGBXLNpDm6rJjHQFSzhL", chargeOptions, null); */ // var service = new ChargeService(); // Charge charge = service.Capture("ch_1DUCTtBXLNpDm6rJzTe5o7Nl", null,null); // YOUR CODE: Save the customer ID and other info in a database for later. // When it's time to charge the customer again, retrieve the customer ID. /* TokenCreateOptions options = new TokenCreateOptions * { * Card = new CreditCardOptions * { * Number = info.cardNumber, * ExpYear = Convert.ToInt32(info.experationDate), * ExpMonth = 11, * Cvc = info.cvvNumber, * * } * }; * * TokenService service = new TokenService(); * Token stripeToken = service.Create(options); */ /*var charge = new ChargeCreateOptions * { * Amount = Convert.ToInt32(43.65 * 100), // In cents, not dollars, times by 100 to convert * Currency = "aud", // or the currency you are dealing with * Description = "2018110901", * CustomerId = "cus_DvIGCEtsC9BZxL", * Capture = false * }; * var services = new ChargeService(); * var response = services.Create(charge);*/ // Record or do something with the charge information // Navigation.PushAsync(new FindSmartBuyer(), true); }
public void SaveInDraft(Object sender, EventArgs e) { try { string UUIDs = ""; bool connect = CrossConnectivity.Current.IsConnected; if (connect) { if (CheckField()) { ApiCalling apiCall = new ApiCalling(); string clientNotificationId = ""; OneSignal.Current.IdsAvailable((playerID, pushToken) => { clientNotificationId = playerID; // App.Current.MainPage.DisplayAlert("playerId", id.ToString(), "OK"); }); Dictionary <string, object> userData = SharedUserData.getUserData; string deliveryDateTime = ""; UUIDs = Guid.NewGuid().ToString(); deliveryDateTime = "Not set";//currentDate.Text + " " + currentTime.Text; TrollyCreation trolly = new TrollyCreation { createdDate = DateTime.Now.ToString("dd/MM/yyyy"), lastModifiedDate = DateTime.Now.ToString("dd/MM/yyyy"), trollyTitle = trolliTitle.Text, trollyDetail = GetItemsInJson(), trolliId = UUIDs, clientId = Convert.ToString(userData["UniqueID"]), status = "Draft", deliveryDateTime = deliveryDateTime, assigneeId = " ", clientNotificationId = clientNotificationId, SBNotificationId = " " }; apiCall.TrollyCreation(trolly); SharedUserData.draftRecord = trolly; // SharedUserData.listStore = new ObservableCollection<ListStores>(); // SharedUserData.addProduct = new ObservableCollection<ListProduct>(); DisplayAlert("", "Trolli saved", "Ok"); // Navigation.PushAsync(new FeesCalculation()); } else { DisplayAlert("", "Enter the name Trolly Title", "Ok"); } } else { DisplayAlert("Uh Oh!", "It seems like you are not connected to internet. Retry once your connections is back", "Exit"); // internetCheck.IsVisible = true; // RetryVariable.IsVisible = true; } }catch (Exception ex) { DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); } }
public async void AssignHandler(Object sender, EventArgs e) { try { if (statusText.Text != "Assign") { activIndicator.IsRunning = true; string SBNotificationid = ""; OneSignal.Current.IdsAvailable((playerID, pushToken) => { SBNotificationid = playerID; // App.Current.MainPage.DisplayAlert("playerId", id.ToString(), "OK"); }); ApiCalling apiCall = new ApiCalling(); var deviceId = CrossDeviceInfo.Current.Id; if (SharedUserData.getUserData == null) { string userId = Convert.ToString(Application.Current.Properties["phoneNumber"]); string userUrl = ApiEndPoints.userDetail + userId; string content = await _client.GetStringAsync(userUrl); List <Dictionary <string, object> > posts = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(content); foreach (Dictionary <string, object> i in posts) { Dictionary <string, object> post = JsonConvert.DeserializeObject <Dictionary <string, object> >(Convert.ToString(i["properties"])); string deviceIdJson = Convert.ToString(post["deviceId"]); if (deviceIdJson == deviceId) { Dictionary <string, object> userDataRecord = JsonConvert.DeserializeObject <Dictionary <string, object> >(Convert.ToString(i["properties"])); SharedUserData.getUserData = userDataRecord; } } } Dictionary <string, object> userData = SharedUserData.getUserData; TrollyCreation ob = new TrollyCreation() { assigneeId = Convert.ToString(userData["UniqueID"]), //Smart Buyer Assigne ID trolliId = notificationAssignIds, // Trolli ID SBNotificationId = SBNotificationid // Smart Buyer OneSignal Notification UDID. }; string data = apiCall.TrollyTestTransaction(ob); // data = "[" + data + "]"; var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(data); string ErrorMessage = ""; if (values != null) { ErrorMessage = values["Error Message"]; } if (ErrorMessage == "Invalid Record") { await DisplayAlert("", "This Trolli has been already assign", "Ok"); } else { await DisplayAlert("", "The Trolli has been assigned to you", "Ok"); apiCall.SendSBNotification(ob.assigneeId, clientNotificationId); statusText.Text = "Assign"; } } else { await DisplayAlert("", "This Trolli has been already assign", "Ok"); } activIndicator.IsRunning = false; } catch (Exception ex) { await DisplayAlert("", ExceptionManagement.LogException(ex), "Ok"); //Exception Class } }