/** * Here the client should connect to their server, process the credit card/instrument * and get back a status indicating whether charging the card was successful or not */ void fetchTransactionStatus(FullWallet fullWallet) { if (mProgressDialog.IsShowing) { mProgressDialog.Dismiss(); } // Log Stripe payment method token, if it exists PaymentMethodToken token = fullWallet.PaymentMethodToken; if (token != null) { // getToken returns a JSON object as a String. Replace newlines to make LogCat output // nicer. The 'id' field of the object contains the Stripe token we are interested in. Android.Util.Log.Debug(TAG, "PaymentMethodToken:" + token.Token.Replace('\n', ' ')); } // NOTE: Send details such as fullWallet.getProxyCard() or fullWallet.getBillingAddress() // to your server and get back success or failure. If you used Stripe for processing, // you can get the token from fullWallet.getPaymentMethodToken() // The following code assumes a successful response and calls notifyTransactionStatus WalletClass.Payments.NotifyTransactionStatus(mGoogleApiClient, WalletUtil.CreateNotifyTransactionStatusRequest(fullWallet.GoogleTransactionId, NotifyTransactionStatusRequest.Status.Success)); Intent intent = new Intent(Activity, typeof(OrderCompleteActivity)); intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask); intent.PutExtra(Constants.EXTRA_FULL_WALLET, fullWallet); StartActivity(intent); }
async Task PerformJudoPayment(FullWallet fullWallet) { var androidPayModel = new AndroidPaymentModel { JudoId = _judo.JudoId, Currency = _judo.Currency, Amount = _judo.Amount, Wallet = new AndroidWalletModel { Environment = WalletEnvironment, PublicKey = Resources.GetString(Resource.String.public_key), GoogleTransactionId = fullWallet.GoogleTransactionId, InstrumentDetails = fullWallet.GetInstrumentInfos()[0].InstrumentDetails, InstrumentType = fullWallet.GetInstrumentInfos()[0].InstrumentType, PaymentMethodToken = fullWallet.PaymentMethodToken.Token } }; var result = await PerformTransaction(androidPayModel); if (result.HasError || "Success".Equals(result.Response.Result)) { Toast.MakeText(_walletFragment.Activity, "Payment successful", ToastLength.Short).Show(); } else if ("Declined".Equals(result.Response.Result)) { Toast.MakeText(_walletFragment.Activity, "Payment declined", ToastLength.Short).Show(); } }
private static void CreateWallet() { Console.Clear(); var walletName = Input.String("Enter walletName: "); string password = "******"; string repeatPassword = "******"; while (password != repeatPassword) { password = Input.Password(); repeatPassword = Input.Password("Enter password again: "); if (password != repeatPassword) { Console.WriteLine("PAsswords do not match"); } } var mnemonic = FullWallet.GenerateNewWallet(GetWalletPath(walletName), password); Console.WriteLine("Please keep mnemonic safe: " + mnemonic); Console.WriteLine(); var wallet = new FullWallet(walletName, GetWalletPath(walletName), password); WalletHandler.PrintWalletAccounts(wallet, blockChainClient); Console.WriteLine(); Console.WriteLine("Press any key"); Console.ReadLine(); }
private static void RecoverWallet() { FullWallet wallet = null; try { string mnemonic = Input.String("Enter mnemonic: "); string password = Input.Password(); string walletName = Input.String("Enter new wallet name"); wallet = FullWallet.Recover(mnemonic, password, GetWalletPath(walletName), walletName); Output.WriteSuccess("Wallet recovered"); Input.EnterKey(); } catch (Exception ex) { Output.WriteError(ex.Message); Input.EnterKey(); } if (wallet != null) { WalletHandler walletHandler = new WalletHandler(wallet, blockChainClient); } }
public override void OnActivityResult(int requestCode, int resultCode, Android.Content.Intent data) { mProgressDialog.Hide(); // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.GetIntExtra(WalletConstants.ExtraErrorCode, -1); } switch (requestCode) { case REQUEST_CODE_RESOLVE_ERR: if (resultCode == (int)Result.Ok) { mGoogleApiClient.Connect(); } else { handleUnrecoverableGoogleWalletError(errorCode); } break; case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case (int)Result.Ok: if (data.HasExtra(WalletConstants.ExtraFullWallet)) { FullWallet fullWallet = data.GetParcelableExtra(WalletConstants.ExtraFullWallet).JavaCast <FullWallet> (); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data.HasExtra(WalletConstants.ExtraMaskedWallet)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.GetParcelableExtra(WalletConstants.ExtraMaskedWallet).JavaCast <MaskedWallet> (); mActivityLaunchIntent.PutExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet); StartActivity(mActivityLaunchIntent); } break; case (int)Result.Canceled: // nothing to do here break; default: handleError(errorCode); break; } break; } }
public WalletHandler(FullWallet wallet, IBlockChainClient blockChainClient) { Wallet = wallet; BlockChainClient = blockChainClient; //new KeyValuePair<string, Action>("accounts",Accounts) Commands.Add("accounts", ViewAccounts); Commands.Add("send", Send); Commands.Add("close", CloseWallet); }
public MainWindow(FullWallet wallet) { Wallet = wallet; Addresses.AddRange(wallet.GetAccounts().Select(a => a.Address)); InitializeComponent(); //this.ownAddress.Text = address; RecalcualteTotalBallance(); //this.ownAddress.Text = wallet.GetAddress(); }
private void Generate_Click(object sender, RoutedEventArgs e) { string password = passwordBox.Password; string name = WalletName.Text; string path = walletStorage.GetWalletFilePath(name); string mnemonic = FullWallet.GenerateNewWallet(path, password); wallet = new FullWallet(name, path, password); Mnemonic.Text = mnemonic; Generate.Visibility = Visibility.Hidden; OpenWallet.Visibility = Visibility.Visible; }
protected override void OnCreate (Android.OS.Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.activity_order_complete); mFullWallet = Intent.GetParcelableExtra (Constants.EXTRA_FULL_WALLET).JavaCast<FullWallet> (); var continueButton = FindViewById<Button> (Resource.Id.button_continue_shopping); continueButton.Click += delegate { var intent = new Intent (this, typeof (ItemListActivity)); intent.AddFlags (ActivityFlags.ClearTask); intent.AddFlags (ActivityFlags.NewTask); StartActivity (intent); }; }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_order_complete); mFullWallet = Intent.GetParcelableExtra(Constants.EXTRA_FULL_WALLET).JavaCast <FullWallet> (); var continueButton = FindViewById <Button> (Resource.Id.button_continue_shopping); continueButton.Click += delegate { var intent = new Intent(this, typeof(ItemListActivity)); intent.AddFlags(ActivityFlags.ClearTask); intent.AddFlags(ActivityFlags.NewTask); StartActivity(intent); }; }
private static void OpenWallet() { try { string walletName = Input.String("Enter wallet name "); string password = Input.Password(); FullWallet wallet = new FullWallet(walletName, GetWalletPath(walletName), password); WalletHandler walletHandler = new WalletHandler(wallet, blockChainClient); walletHandler.Run(); } catch (Exception ex) { Output.WriteError(ex.Message); Input.EnterKey(); } }
public static void PrintWalletAccounts(FullWallet wallet, IBlockChainClient blockChainClient) { var accounts = wallet.GetAccounts(); ulong totalBallance = 0; ulong totalUnconfirmedBallance = 0; for (int i = 0; i < accounts.Count; i++) { Console.WriteLine($"**** Account {i}"); Console.WriteLine($"PrivateKey: " + accounts[i].PrivateKey); Console.WriteLine($"Address: " + accounts[i].Address); try { ulong ballance = blockChainClient.GetBalance(accounts[i].Address); totalBallance += ballance; ulong unconfirmedBallance = blockChainClient.GetBalance(accounts[i].Address, true); totalUnconfirmedBallance += unconfirmedBallance; Console.WriteLine($"Balance: " + ballance.GetFormattedTokens()); if (ballance != unconfirmedBallance) { Console.WriteLine($"Unconfirmed: " + unconfirmedBallance.GetFormattedTokens()); } } catch (Exception) { Output.WriteError("Cannot retreive balance, could not connect to node"); } Console.WriteLine(); Console.WriteLine(); } Console.WriteLine($"Total balance: {totalBallance.GetFormattedTokens()}"); if (totalUnconfirmedBallance > 0 && totalUnconfirmedBallance != totalBallance) { Console.WriteLine($"Total Unconfirmed balance: {totalUnconfirmedBallance.GetFormattedTokens()}"); } }
async void PerformJudoPayment(FullWallet fullWallet) { var androidPayModel = new AndroidPaymentModel() { JudoId = _judo.JudoId, Currency = _judo.Currency, Amount = _judo.Amount, Wallet = new AndroidWalletModel() { Environment = WalletEnvironment, PublicKey = Resources.GetString(Resource.String.public_key), GoogleTransactionId = fullWallet.GoogleTransactionId, InstrumentDetails = fullWallet.GetInstrumentInfos()[0].InstrumentDetails, InstrumentType = fullWallet.GetInstrumentInfos()[0].InstrumentType, Version = fullWallet.VersionCode, PaymentMethodToken = fullWallet.PaymentMethodToken.Token } }; var result = await PerformTransaction(androidPayModel); if (result.HasError || "Success".Equals(result.Response.Result)) { Toast.MakeText(_walletFragment.Activity, "Payment successful", ToastLength.Short).Show(); } else if ("Declined".Equals(result.Response.Result)) { Toast.MakeText(_walletFragment.Activity, "Payment declined", ToastLength.Short).Show(); } }
/** * Here the client should connect to their server, process the credit card/instrument * and get back a status indicating whether charging the card was successful or not */ void fetchTransactionStatus (FullWallet fullWallet) { if (mProgressDialog.IsShowing) mProgressDialog.Dismiss(); // Log Stripe payment method token, if it exists PaymentMethodToken token = fullWallet.PaymentMethodToken; if (token != null) { // getToken returns a JSON object as a String. Replace newlines to make LogCat output // nicer. The 'id' field of the object contains the Stripe token we are interested in. Android.Util.Log.Debug (TAG, "PaymentMethodToken:" + token.Token.Replace ('\n', ' ')); } // NOTE: Send details such as fullWallet.getProxyCard() or fullWallet.getBillingAddress() // to your server and get back success or failure. If you used Stripe for processing, // you can get the token from fullWallet.getPaymentMethodToken() // The following code assumes a successful response and calls notifyTransactionStatus WalletClass.Payments.NotifyTransactionStatus (mGoogleApiClient, WalletUtil.CreateNotifyTransactionStatusRequest (fullWallet.GoogleTransactionId, NotifyTransactionStatusRequest.Status.Success)); Intent intent = new Intent(Activity, typeof (OrderCompleteActivity)); intent.SetFlags (ActivityFlags.ClearTask | ActivityFlags.NewTask); intent.PutExtra (Constants.EXTRA_FULL_WALLET, fullWallet); StartActivity(intent); }