Ejemplo n.º 1
0
        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
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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
            }
        }
Ejemplo n.º 4
0
        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");
            }
        }