Ejemplo n.º 1
0
        /// <summary>
        /// Add a new CBPayPalBillItem to the current bill
        /// </summary>
        /// <param name="newItem">The item to be added</param>
        public void AddNewItem(CBPayPalBillItem newItem)
        {
            if (this.Items == null)
                this._items = new List<CBPayPalBillItem>();

            this._items.Add(newItem);
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            CBPayPalBill bill = new CBPayPalBill();
            bill.Currency = "USD";
            bill.Description = "Test transaction for $9.99";
            bill.InvoiceNumber = "TST-INVOICE-001";
            bill.Name = "Test transaction";

            CBPayPalBillItem billItem = new CBPayPalBillItem();
            billItem.Amount = 9.99;
            billItem.Description = "Test item for $9.99";
            billItem.Name = "Test item";
            billItem.Quantity = 1;
            billItem.Tax = 0.0;

            bill.AddNewItem(billItem);

            App.helper.PreparePayPalPurchase(bill, true, delegate(CBResponseInfo resp)
            {

                this.PayPalWebView.Visibility = Windows.UI.Xaml.Visibility.Visible;

                string url = Convert.ToString(((Dictionary<string, object>)resp.Data)["checkout_url"]);
                System.Diagnostics.Debug.WriteLine("received response : " + resp.OutputString);

                this.PayPalWebView.Navigate(new Uri(url));

                this.PayPalWebView.LoadCompleted += delegate(object webViewSender, NavigationEventArgs webViewE)
                {
                    //System.Diagnostics.Debug.WriteLine("started navigating to " + e.Uri.AbsoluteUri);
                    if (App.helper.IsPayPayPaymentComplete(webViewE.Uri, delegate(CBResponseInfo finalResp)
                    {
                        // you can read the payment details
                        this.PayPalWebView.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                        return true;
                    }));
                };

                return true;
            });
        }
        private void PayPalButton_Click(object sender, RoutedEventArgs e)
        {
            if (App.helper != null)
            {
                CBPayPalBillItem item = new CBPayPalBillItem();
                item.Name = "Test item 1";
                item.Description = "Test item 1 for $9.99";
                item.Amount = 9.99;
                item.Tax = 0;
                item.Quantity = 1;

                CBPayPalBill bill = new CBPayPalBill();
                bill.Name = "Test PayPal bill 1";
                bill.Description = "Test PayPal bill 1 for $9.99";
                bill.Currency = "USD";
                bill.InvoiceNumber = "TEST_INV_1";
                bill.AddNewItem(item);

                App.helper.PreparePayPalPurchase(bill, false, delegate(CBResponseInfo resp)
                {
                    if (resp.Status)
                    {
                        if (((Dictionary<string, object>)resp.Data).ContainsKey("checkout_url"))
                        {
                            App.PayPalCheckoutUrl = Convert.ToString(((Dictionary<string, object>)resp.Data)["checkout_url"]);
                            NavigationService.Navigate(new Uri("/PayPalBrowser.xaml", UriKind.Relative));
                        }
                    }
                    return true;
                });
            }
        }