Beispiel #1
0
        /**
         * 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(Android.Gms.Wallet.FullWallet fullWallet)
        {
            if (mProgressDialog.IsShowing)
            {
                mProgressDialog.Dismiss();
            }

            // Log Stripe payment method token, if it exists
            Android.Gms.Wallet.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.JavaCast <IParcelable>());

            StartActivity(intent);
        }
Beispiel #2
0
        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(Android.Gms.Wallet.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(Android.Gms.Wallet.WalletConstants.ExtraFullWallet))
                    {
                        Android.Gms.Wallet.FullWallet fullWallet =
                            data.GetParcelableExtra(Android.Gms.Wallet.WalletConstants.ExtraFullWallet).JavaCast <Android.Gms.Wallet.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(Android.Gms.Wallet.WalletConstants.ExtraMaskedWallet))
                    {
                        // re-launch the activity with new masked wallet information
                        mMaskedWallet = data.GetParcelableExtra(Android.Gms.Wallet.WalletConstants.ExtraMaskedWallet).JavaCast <Android.Gms.Wallet.MaskedWallet> ();
                        mActivityLaunchIntent.PutExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet.JavaCast <IParcelable>());

                        StartActivity(mActivityLaunchIntent);
                    }
                    break;

                case (int)Result.Canceled:
                    // nothing to do here
                    break;

                default:
                    handleError(errorCode);
                    break;
                }
                break;
            }
        }
Beispiel #3
0
        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 <Android.Gms.Wallet.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);
            };
        }