public DirectpaymentViewController(IntPtr handle) : base(handle) { directpayment = new Directpayment(this); directpayment.OnSSLServerAuthentication += (sender, e) => { e.Accept = true; //accept all servers by default, please update to increase security }; }
public DirectpaymentViewController (IntPtr handle) : base (handle) { directpayment = new Directpayment (this); directpayment.OnSSLServerAuthentication += (sender, e) => { e.Accept = true; //accept all servers by default, please update to increase security }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); directpayment = new Directpayment(this); directpayment.OnSSLServerAuthentication += (object sender, DirectpaymentSSLServerAuthenticationEventArgs e) => { e.Accept = true; }; ShowMainView (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); directpayment = new Directpayment(this); directpayment.OnSSLServerAuthentication += (object sender, DirectpaymentSSLServerAuthenticationEventArgs e) => { e.Accept = true; }; ShowMainView(); }
protected override async void OnCreate(Bundle savedInstanceState) { Xamarin.Insights.Initialize(XamarinInsights.ApiKey, this); base.OnCreate(savedInstanceState); directpayment = new Directpayment(this); directpayment.OnSSLServerAuthentication += (object sender, DirectpaymentSSLServerAuthenticationEventArgs e) => { e.Accept = true; }; //Stripe.StripeClient.DefaultPublishableKey = "sk_test_1sTZuEyHl6nZFhZJ3lnEgF8Y"; SetContentView(Resource.Layout.Pay); EditText txtFirstName = FindViewById <EditText> (Resource.Id.txtFirstName); EditText txtLastName = FindViewById <EditText> (Resource.Id.txtLastName); EditText txtAddress = FindViewById <EditText> (Resource.Id.txtAddress); EditText txtCity = FindViewById <EditText> (Resource.Id.txtCity); EditText txtState = FindViewById <EditText> (Resource.Id.txtState); EditText txtZip = FindViewById <EditText> (Resource.Id.txtZip); EditText txtIPAddress = FindViewById <EditText> (Resource.Id.txtIPAddress); EditText txtAmount = FindViewById <EditText> (Resource.Id.txtAmount); EditText txtDescription = FindViewById <EditText> (Resource.Id.txtDescription); Button btnConfigure = FindViewById <Button> (Resource.Id.btnConfigure); Button btnCardInfo = FindViewById <Button> (Resource.Id.btnCardInfo); Button btnAuthorize = FindViewById <Button> (Resource.Id.btnAuthorize); btnAuthorize.Click += (object sender, EventArgs e) => { try { directpayment.URL = "https://api-3t.sandbox.paypal.com/nvp"; // Test Server URL directpayment.User = apiUsername; directpayment.Password = apiPassword; directpayment.Signature = apiSignature; directpayment.OrderTotal = txtAmount.Text; directpayment.OrderDescription = txtDescription.Text; nsoftware.InPayPal.Card card = new nsoftware.InPayPal.Card(); card.CardType = CardTypes.ccVisa; card.Number = cardNumber; card.ExpMonth = Convert.ToInt32(cardExpMonth); card.ExpYear = Convert.ToInt32(cardExpYear); card.CVV = cardCVVData; directpayment.Card = card; DirectPaymentPayer payer = new DirectPaymentPayer(); payer.FirstName = txtFirstName.Text; payer.LastName = txtLastName.Text; payer.Street1 = txtAddress.Text; payer.City = txtCity.Text; payer.State = txtState.Text; payer.Zip = txtZip.Text; payer.IPAddress = txtIPAddress.Text; directpayment.Payer = payer; directpayment.Sale(); /*string results = "Ack : " + directpayment.Ack + "\r\n"; * results += "Amt : " + directpayment.Response.Amount + "\r\n"; * results += "AVS : " + directpayment.Response.AVS + "\r\n"; * results += "CVV : " + directpayment.Response.CVV + "\r\n"; * results += "TxnId: " + directpayment.Response.TransactionId + "\r\n"; * txtResults.Text = results;*/ //ShowResultsView(); } catch (InPayPalDirectpaymentException ex) { //ShowMessage ("Error", ex.Message); } }; /*var b = new WalletClass.WalletOptions.Builder () * .SetEnvironment (WalletConstants.EnvironmentSandbox) * .SetTheme (WalletConstants.ThemeLight) * .Build (); * * googleApiClient = new GoogleApiClient.Builder (this) * .AddConnectionCallbacks (this) * .AddOnConnectionFailedListener (this) * .AddApi (WalletClass.API, b) * .Build (); * * * //var token = await StripeClient.CreateToken (c, MainActivity.STRIPE_PUBLISHABLE_KEY); * var walletFragment = SupportWalletFragment.NewInstance (WalletFragmentOptions.NewBuilder () * .SetEnvironment (WalletConstants.EnvironmentSandbox) * .SetMode (WalletFragmentMode.BuyButton) * .SetTheme (WalletConstants.ThemeLight) * .SetFragmentStyle (new WalletFragmentStyle () * .SetBuyButtonText (BuyButtonText.BuyWithGoogle) * .SetBuyButtonAppearance (BuyButtonAppearance.Classic) * .SetBuyButtonWidth (Dimension.MatchParent)) * .Build ()); * * var maskedWalletRequest = MaskedWalletRequest.NewBuilder () * * // Request credit card tokenization with Stripe by specifying tokenization parameters: * .SetPaymentMethodTokenizationParameters (PaymentMethodTokenizationParameters.NewBuilder () * .SetPaymentMethodTokenizationType (PaymentMethodTokenizationType.PaymentGateway) * .AddParameter ("gateway", "stripe") * .AddParameter ("stripe:publishableKey", Stripe.StripeClient.DefaultPublishableKey) * .AddParameter ("stripe:version", "1.15.1") * .Build ()) * * // You want the shipping address: * .SetShippingAddressRequired (false) * * .SetMerchantName ("Llamanators") * .SetPhoneNumberRequired (false) * .SetShippingAddressRequired (false) * * // Price set as a decimal: * .SetEstimatedTotalPrice ("20.00") * .SetCurrencyCode ("USD") * * .Build(); * * // Set the parameters: * var initParams = WalletFragmentInitParams.NewBuilder () * .SetMaskedWalletRequest (maskedWalletRequest) * .SetMaskedWalletRequestCode (LOAD_MASKED_WALLET_REQ_CODE) * .Build (); * * // Initialize the fragment: * walletFragment.Initialize (initParams); * * SupportFragmentManager.BeginTransaction ().Replace (Resource.Id.frame_action, walletFragment).Commit ();*/ //supportToolbar = FindViewById<SupportToolbar> (Resource.Layout.order_menu); //SetSupportActionBar (supportToolbar); //SupportActionBar.SetHomeButtonEnabled(true); //SupportActionBar.SetDisplayHomeAsUpEnabled (true); //SupportActionBar.Title = "TapTap Coffee"; //order = FindViewById<TextView> (Resource.Id.txtListHeader); //order.Text = string.Concat (TempStorage.Size, " ", TempStorage.Coffee, " ", "($", TempStorage.Price, ")"); //loadingBar = FindViewById<ProgressBar> (Resource.Id.pbLoading); //loadingBar.Visibility = ViewStates.Invisible;*/ favChecked = Intent.GetBooleanExtra("Favourite", false); //stripeView = FindViewById<Stripe.StripeView> (Resource.Id.stripeView); //btnPay = FindViewById<Button> (Resource.Id.btnPay); //btnPay.Click += delegate { /* var c = stripeView.Card; * * if (!c.IsCardValid) { * var errorMsg = "Invalid Card Information"; * * if (!c.IsNumberValid) * errorMsg = "Invalid Card Number"; * else if (!c.IsValidExpiryDate) * errorMsg = "Invalid Card Expiry Date"; * else if (!c.IsValidCvc) * errorMsg = "Invalid CVC"; * * Toast.MakeText(this, errorMsg, ToastLength.Short).Show(); * } else { * // c.Name = name.Text; * // c.AddressLine1 = address1.Text; * // c.AddressLine2 = address2.Text; * // c.AddressCity = city.Text; * // c.AddressState = state.Text; * // c.AddressZip = zip.Text; * // c.AddressCountry = country.Text; * * try { * var token = StripeClient.CreateToken (c, TempStorage.PublishableKey); * * if (token != null) { * * * * //TODO: Send token to your server to process a payment with * * var msg = string.Format ("Good news! Stripe turned your credit card into a token: \n{0} \n\nYou can follow the instructions in the README to set up Parse as an example backend, or use this token to manually create charges at dashboard.stripe.com .", * token.Id); * * Toast.MakeText(this, msg, ToastLength.Long).Show(); * } else { * Toast.MakeText(this, "Failed to create Token", ToastLength.Short).Show(); * } * } catch (Exception ex) { * Toast.MakeText (this, "Failure: " + ex.Message, ToastLength.Short).Show (); * } * }*/ }
protected override async void OnCreate (Bundle savedInstanceState) { Xamarin.Insights.Initialize (XamarinInsights.ApiKey, this); base.OnCreate (savedInstanceState); directpayment = new Directpayment(this); directpayment.OnSSLServerAuthentication += (object sender, DirectpaymentSSLServerAuthenticationEventArgs e) => { e.Accept = true; }; //Stripe.StripeClient.DefaultPublishableKey = "sk_test_1sTZuEyHl6nZFhZJ3lnEgF8Y"; SetContentView (Resource.Layout.Pay); EditText txtFirstName = FindViewById<EditText> (Resource.Id.txtFirstName); EditText txtLastName = FindViewById<EditText> (Resource.Id.txtLastName); EditText txtAddress = FindViewById<EditText> (Resource.Id.txtAddress); EditText txtCity = FindViewById<EditText> (Resource.Id.txtCity); EditText txtState = FindViewById<EditText> (Resource.Id.txtState); EditText txtZip = FindViewById<EditText> (Resource.Id.txtZip); EditText txtIPAddress = FindViewById<EditText> (Resource.Id.txtIPAddress); EditText txtAmount = FindViewById<EditText> (Resource.Id.txtAmount); EditText txtDescription = FindViewById<EditText> (Resource.Id.txtDescription); Button btnConfigure = FindViewById<Button> (Resource.Id.btnConfigure); Button btnCardInfo = FindViewById<Button> (Resource.Id.btnCardInfo); Button btnAuthorize = FindViewById<Button> (Resource.Id.btnAuthorize); btnAuthorize.Click += (object sender, EventArgs e) => { try { directpayment.URL = "https://api-3t.sandbox.paypal.com/nvp"; // Test Server URL directpayment.User = apiUsername; directpayment.Password = apiPassword; directpayment.Signature = apiSignature; directpayment.OrderTotal = txtAmount.Text; directpayment.OrderDescription = txtDescription.Text; nsoftware.InPayPal.Card card = new nsoftware.InPayPal.Card (); card.CardType = CardTypes.ccVisa; card.Number = cardNumber; card.ExpMonth = Convert.ToInt32 (cardExpMonth); card.ExpYear = Convert.ToInt32 (cardExpYear); card.CVV = cardCVVData; directpayment.Card = card; DirectPaymentPayer payer = new DirectPaymentPayer (); payer.FirstName = txtFirstName.Text; payer.LastName = txtLastName.Text; payer.Street1 = txtAddress.Text; payer.City = txtCity.Text; payer.State = txtState.Text; payer.Zip = txtZip.Text; payer.IPAddress = txtIPAddress.Text; directpayment.Payer = payer; directpayment.Sale (); /*string results = "Ack : " + directpayment.Ack + "\r\n"; results += "Amt : " + directpayment.Response.Amount + "\r\n"; results += "AVS : " + directpayment.Response.AVS + "\r\n"; results += "CVV : " + directpayment.Response.CVV + "\r\n"; results += "TxnId: " + directpayment.Response.TransactionId + "\r\n"; txtResults.Text = results;*/ //ShowResultsView(); } catch (InPayPalDirectpaymentException ex) { //ShowMessage ("Error", ex.Message); } }; /*var b = new WalletClass.WalletOptions.Builder () .SetEnvironment (WalletConstants.EnvironmentSandbox) .SetTheme (WalletConstants.ThemeLight) .Build (); googleApiClient = new GoogleApiClient.Builder (this) .AddConnectionCallbacks (this) .AddOnConnectionFailedListener (this) .AddApi (WalletClass.API, b) .Build (); //var token = await StripeClient.CreateToken (c, MainActivity.STRIPE_PUBLISHABLE_KEY); var walletFragment = SupportWalletFragment.NewInstance (WalletFragmentOptions.NewBuilder () .SetEnvironment (WalletConstants.EnvironmentSandbox) .SetMode (WalletFragmentMode.BuyButton) .SetTheme (WalletConstants.ThemeLight) .SetFragmentStyle (new WalletFragmentStyle () .SetBuyButtonText (BuyButtonText.BuyWithGoogle) .SetBuyButtonAppearance (BuyButtonAppearance.Classic) .SetBuyButtonWidth (Dimension.MatchParent)) .Build ()); var maskedWalletRequest = MaskedWalletRequest.NewBuilder () // Request credit card tokenization with Stripe by specifying tokenization parameters: .SetPaymentMethodTokenizationParameters (PaymentMethodTokenizationParameters.NewBuilder () .SetPaymentMethodTokenizationType (PaymentMethodTokenizationType.PaymentGateway) .AddParameter ("gateway", "stripe") .AddParameter ("stripe:publishableKey", Stripe.StripeClient.DefaultPublishableKey) .AddParameter ("stripe:version", "1.15.1") .Build ()) // You want the shipping address: .SetShippingAddressRequired (false) .SetMerchantName ("Llamanators") .SetPhoneNumberRequired (false) .SetShippingAddressRequired (false) // Price set as a decimal: .SetEstimatedTotalPrice ("20.00") .SetCurrencyCode ("USD") .Build(); // Set the parameters: var initParams = WalletFragmentInitParams.NewBuilder () .SetMaskedWalletRequest (maskedWalletRequest) .SetMaskedWalletRequestCode (LOAD_MASKED_WALLET_REQ_CODE) .Build (); // Initialize the fragment: walletFragment.Initialize (initParams); SupportFragmentManager.BeginTransaction ().Replace (Resource.Id.frame_action, walletFragment).Commit ();*/ //supportToolbar = FindViewById<SupportToolbar> (Resource.Layout.order_menu); //SetSupportActionBar (supportToolbar); //SupportActionBar.SetHomeButtonEnabled(true); //SupportActionBar.SetDisplayHomeAsUpEnabled (true); //SupportActionBar.Title = "TapTap Coffee"; //order = FindViewById<TextView> (Resource.Id.txtListHeader); //order.Text = string.Concat (TempStorage.Size, " ", TempStorage.Coffee, " ", "($", TempStorage.Price, ")"); //loadingBar = FindViewById<ProgressBar> (Resource.Id.pbLoading); //loadingBar.Visibility = ViewStates.Invisible;*/ favChecked = Intent.GetBooleanExtra ("Favourite", false); //stripeView = FindViewById<Stripe.StripeView> (Resource.Id.stripeView); //btnPay = FindViewById<Button> (Resource.Id.btnPay); //btnPay.Click += delegate { /* var c = stripeView.Card; if (!c.IsCardValid) { var errorMsg = "Invalid Card Information"; if (!c.IsNumberValid) errorMsg = "Invalid Card Number"; else if (!c.IsValidExpiryDate) errorMsg = "Invalid Card Expiry Date"; else if (!c.IsValidCvc) errorMsg = "Invalid CVC"; Toast.MakeText(this, errorMsg, ToastLength.Short).Show(); } else { // c.Name = name.Text; // c.AddressLine1 = address1.Text; // c.AddressLine2 = address2.Text; // c.AddressCity = city.Text; // c.AddressState = state.Text; // c.AddressZip = zip.Text; // c.AddressCountry = country.Text; try { var token = StripeClient.CreateToken (c, TempStorage.PublishableKey); if (token != null) { //TODO: Send token to your server to process a payment with var msg = string.Format ("Good news! Stripe turned your credit card into a token: \n{0} \n\nYou can follow the instructions in the README to set up Parse as an example backend, or use this token to manually create charges at dashboard.stripe.com .", token.Id); Toast.MakeText(this, msg, ToastLength.Long).Show(); } else { Toast.MakeText(this, "Failed to create Token", ToastLength.Short).Show(); } } catch (Exception ex) { Toast.MakeText (this, "Failure: " + ex.Message, ToastLength.Short).Show (); } }*/ }