Exemple #1
0
        }                                                           /* this simple sample uses a no op */

        /// <summary>
        /// Illustrate setting up a recovery rule more complex than "normal consumer"
        /// mode, without the "normal consumer" shortcuts.
        /// </summary>
        /// <param name="newMember">newly-created member we are setting up</param>
        /// <param name="tokenClient">SDK client</param>
        /// <param name="agentAlias">Alias of recovery agent.</param>
        public void SetUpComplexRecoveryRule(
            UserMember newMember,
            Tokenio.User.TokenClient tokenClient,
            Alias agentAlias)
        {
            // setUpComplex begin snippet to include in docs
            // Someday in the future, this user might ask the recovery agent
            // "Please tell Token that I am the member with ID m:12345678 ."
            // While we're setting up this new member, we need to tell the
            // recovery agent the new member ID so the agent can "remember" later.
            TellRecoveryAgentMemberId(newMember.MemberId());

            string agentId = tokenClient.GetMemberIdBlocking(agentAlias);

            RecoveryRule recoveryRule = new RecoveryRule {
                PrimaryAgent = agentId
            };

            // This example doesn't call .setSecondaryAgents ,
            // but could have. If it had, then recovery would have
            // required one secondary agent authorization along with
            // the primary agent authorization.
            newMember.AddRecoveryRuleBlocking(recoveryRule);
            // setUpComplex done snippet to include in docs
        }
Exemple #2
0
        public void CreatePaymentTokenTest()
        {
            using (Tokenio.User.TokenClient tokenClient = TestUtil.CreateClient())
            {
                UserMember member = TestUtil.CreateMemberAndLinkAccounts(tokenClient);

                Assert.Equal(tokenClient.GetMemberBlocking(member.MemberId()).MemberId(), member.MemberId());

                member.DeleteMemberBlocking();


                Assert.Throws <AggregateException>(() =>
                                                   tokenClient.GetMemberBlocking(member.MemberId())

                                                   );
            }
        }
Exemple #3
0
        /// <summary>
        /// Sets a profile name and picture.
        /// </summary>
        /// <param name="member">member</param>
        /// <returns>profile</returns>
        public static Profile Profiles(UserMember member)
        {
            Profile name = new Profile
            {
                DisplayNameFirst = "Tycho",
                DisplayNameLast  = "Nestoris"
            };

            member.SetProfileBlocking(name);
            member.SetProfilePictureBlocking("image/jpeg", PICTURE);

            Profile profile = member.GetProfileBlocking(member.MemberId());

            return(profile);
        }
Exemple #4
0
        public void provisionDevice()
        {
            using (Tokenio.User.TokenClient remoteDevice = TestUtil.CreateClient())
            {
                Alias      alias        = TestUtil.RandomAlias();
                UserMember remoteMember = remoteDevice.CreateMemberBlocking(alias);
                remoteMember.SubscribeToNotifications("iron");

                Tokenio.User.TokenClient localDeviceClient = TestUtil.CreateClient();
                Key key = ProvisionDeviceSample.ProvisionDevice(localDeviceClient, alias);
                remoteMember.ApproveKeyBlocking(key);

                UserMember local = ProvisionDeviceSample.UseProvisionedDevice(localDeviceClient, alias);

                Assert.Equal(local.MemberId(), remoteMember.MemberId());
            }
        }
Exemple #5
0
        /// <summary>
        /// Redeems a transfer token to transfer money from payer bank account to payee bank account.
        /// </summary>
        /// <param name="payee">payee Token member</param>
        /// <param name="accountId">account id of the payee</param>
        /// <param name="tokenId">ID of the token to redeem</param>
        /// <returns>a transfer Transfer</returns>
        public static Transfer RedeemTransferToken(
            UserMember payee,
            string accountId, // account ID of the payee
            string tokenId)
        {                     // ID of token to redeem
          // We'll use this as a reference ID. Normally, a payee who
          // explicitly sets a reference ID would use an ID from a db.
          // E.g., an online merchant might use the ID of a "shopping cart".
          // We don't have a db, so we fake it with a random string:
            string cartId = Util.Nonce();

            // Retrieve a transfer token to redeem.
            Token transferToken = payee.GetTokenBlocking(tokenId);

            // Set token destination
            TransferDestination tokenDestination = new TransferDestination
            {
                Token = new TransferDestination.Types.Token
                {
                    MemberId  = payee.MemberId(),
                    AccountId = accountId
                }
            };



            // Payee redeems a transfer token.
            // Money is transferred to a payee bank account.
            Transfer transfer = payee.RedeemTokenBlocking(
                transferToken,
                tokenDestination,
                // if refId not set, transfer will have random refID:
                cartId);

            return(transfer);
        }
Exemple #6
0
 public void CreatePaymentTokenWithOtherOptionsTest()
 {
     using (Tokenio.User.TokenClient tokenClient = TestUtil.CreateClient())
     {
         UserMember payer = TestUtil.CreateMemberAndLinkAccounts(tokenClient);
         UserMember payee = tokenClient.CreateMemberBlocking(TestUtil.RandomAlias());
         Token      token = CreateTransferTokenSample.CreateTransferTokenWithOtherOptions(payer, payee.MemberId());
         Assert.NotNull(token);
     }
 }