Пример #1
0
        async public void buy_cart()
        {
            try
            {
                if (list_cart.Count() == 0)
                {
                    await new MessageDialog("Le panier est vide !").ShowAsync();
                    return;
                }
                //buy_cart_after_pp_validation();
                //[email protected]
                //PayPal.Checkout.BuyNow purchase = new PayPal.Checkout.BuyNow("*****@*****.**");
                PayPal.Checkout.BuyNow purchase = new PayPal.Checkout.BuyNow("*****@*****.**");

                purchase.UseSandbox = true;

                purchase.Currency = "EUR";

                // Use the ItemBuilder to create a new example item
                PayPal.Checkout.ItemBuilder itemBuilder = new PayPal.Checkout.ItemBuilder("W8_PP")
                    .ID("W8_pp")
                    .Price(cart_price.ToString())
                    .Description("")
                    .Quantity(1);

                // Add the item to the purchase,
                purchase.AddItem(itemBuilder.Build());

                // Attach event handlers so you will be notified of important events
                // The BuyNow interface provides 5 events - Start, Auth, Cancel, Complete and Error
                // See http://paypal.github.io/Windows8SDK/csharp.html#Events for more
                purchase.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, eventArg) =>
                {
                    this.txt_pp = "Une erreur est survenue lors du paiement: " + eventArg.Message;
                });
                purchase.Auth += new EventHandler<PayPal.Checkout.Event.AuthEventArgs>((source, eventArg) =>
                {
                    this.txt_pp = "Authentification: " + eventArg.Token;
                });
                purchase.Start += new EventHandler<PayPal.Checkout.Event.StartEventArgs>((source, eventArg) =>
                {
                    this.txt_pp = "Chargement de PayPal...";
                });
                purchase.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, eventArg) =>
                {
                    //buy_cart_after_pp_validation();
                    this.txt_pp = "Le paiement à été validé: " + eventArg.TransactionID;
                    this.pp_transac_id = eventArg.TransactionID;
                    this.buy_cart_after_pp_validation();
                });
                purchase.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, eventArg) =>
                {
                    this.txt_pp = "Le paiement à été annulé par l'utilisateur.";
                });

                // Launch the secure PayPal interface. This is an asynchronous method
                await purchase.Execute();
            }
            catch (Exception Error)
            {
                new MessageDialog("Erreur lors de la connexion avec PayPal").ShowAsync();
            }
        }// buy_cart_after_pp_validation
Пример #2
0
        private async void puchaseButtonClick(object sender, RoutedEventArgs e)
        {
            buyNow = new BuyNow("*****@*****.**");
            buyNow.UseSandbox = true;
            // Set the currency to use US Dollars
            buyNow.Currency = "USD";

            // Use the ItemBuilder to create a new example item
            PayPal.Checkout.ItemBuilder itemBuilder = new PayPal.Checkout.ItemBuilder("Example Item")
                .ID(item.Id)
                .Price(item.Price)
                .Description(item.Description)
                .Quantity(item.Quantity);

            // Add the item to the purchase,
            buyNow.AddItem(itemBuilder.Build());

            // Attach event handlers so you will be notified of important events
            // The BuyNow interface provides 5 events - Start, Auth, Cancel, Complete and Error
            // See http://paypal.github.io/Windows8SDK/csharp.html#Events for more
            buyNow.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, eventArg) =>
            {
                this.tbBarcodeType.Text = "There was an error processing your payment: " + eventArg.Message;
            });
            buyNow.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, eventArg) =>
            {
                this.tbBarcodeType.Text = "Payment is complete. Transaction id: " + eventArg.TransactionID;
            });
            buyNow.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, eventArg) =>
            {
                this.tbBarcodeType.Text = "Payment was canceled by the user.";
            });

            // Launch the secure PayPal interface. This is an asynchronous method
            await buyNow.Execute();

        }