private async void PlaceOrder()
        {
            try
            {
                CanEdit = false;

                var logger = new FileLogger(LogLevel.Debug, "PayPal.log");

                if (logger.Exists())
                    logger.AddBlankLine();

                var config = new Config()
                {
                    Endpoint = Properties.Settings.Default.PayPalEndpoint,
                    ClientId = Properties.Settings.Default.PayPalClientId,
                    Secret = Properties.Settings.Default.PayPalSecret
                };

                var task = Task<Outcome>.Factory.StartNew(
                    () => PayPalHelper.PlaceOrder(logger, config, CurrentOrder, false));

                await task;

                if (OpenLogWhenDone)
                    Process.Start("PayPal.log");

                MessageBox.Show(string.Format("{0} (PaymentId: {1})",
                    task.Result.State, task.Result.PaymentId));
            }
            catch (PayPalException error)
            {
                var details = new StringBuilder();

                foreach (var detail in error.Details)
                {
                    if (details.Length != 0)
                        details.Append(", ");

                    details.Append(detail.Key);
                    details.Append('=');
                    details.Append(detail.Value);
                }

                MessageBox.Show(string.Format("{0} (DebugId: {1}, Details: {2})",
                    error.Name, error.DebugId, details));
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }
            finally
            {
                CanEdit = true;
            }
        }
        private async void PlaceOrder()
        {
            try
            {
                CanEdit = false;

                var logger = new FileLogger(LogLevel.Debug, "PayPal.log");

                if (logger.Exists())
                {
                    logger.AddBlankLine();
                }

                var config = new Config()
                {
                    Endpoint = Properties.Settings.Default.PayPalEndpoint,
                    ClientId = Properties.Settings.Default.PayPalClientId,
                    Secret   = Properties.Settings.Default.PayPalSecret
                };

                var task = Task <Outcome> .Factory.StartNew(
                    () => PayPalHelper.PlaceOrder(logger, config, CurrentOrder, false));

                await task;

                if (OpenLogWhenDone)
                {
                    Process.Start("PayPal.log");
                }

                MessageBox.Show(string.Format("{0} (PaymentId: {1})",
                                              task.Result.State, task.Result.PaymentId));
            }
            catch (PayPalException error)
            {
                var details = new StringBuilder();

                foreach (var detail in error.Details)
                {
                    if (details.Length != 0)
                    {
                        details.Append(", ");
                    }

                    details.Append(detail.Key);
                    details.Append('=');
                    details.Append(detail.Value);
                }

                MessageBox.Show(string.Format("{0} (DebugId: {1}, Details: {2})",
                                              error.Name, error.DebugId, details));
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }
            finally
            {
                CanEdit = true;
            }
        }