Exemplo n.º 1
0
        public void AddAndGetTransferTokenRequest()
        {
            var storedPayload = new TokenRequestPayload
            {
                UserRefId   = Util.Nonce(),
                RefId       = Util.Nonce(),
                RedirectUrl = tokenUrl,
                To          = new TokenMember
                {
                    Id = member.MemberId()
                },
                Description   = Util.Nonce(),
                CallbackState = Util.Nonce(),
                TransferBody  = new TokenRequestPayload.Types.TransferBody
                {
                    Amount       = "10.0",
                    Currency     = "EUR",
                    Instructions = new TransferInstructions(),
                }
            };

            var storedOptions = new Tokenio.Proto.Common.TokenProtos.TokenRequestOptions
            {
                BankId           = "iron",
                ReceiptRequested = false
            };

            var requestId = member.StoreTokenRequestBlocking(storedPayload, storedOptions);

            Assert.NotEmpty(requestId);
            var retrievedRequest = tokenClient.RetrieveTokenRequestBlocking(requestId);

            Assert.Equal(storedPayload, retrievedRequest.GetTokenRequestPayload());
            Assert.Equal(storedOptions, retrievedRequest.GetTokenRequestOptions());
        }
Exemplo n.º 2
0
        public void AddAndGetTokenRequest_WrongMember()
        {
            var storedPayload = new TokenRequestPayload
            {
                UserRefId   = Util.Nonce(),
                RedirectUrl = tokenUrl,
                To          = new TokenMember
                {
                    Id = tokenClient.CreateMemberBlocking().MemberId()
                },
                Description   = Util.Nonce(),
                CallbackState = Util.Nonce(),
                TransferBody  = new TokenRequestPayload.Types.TransferBody
                {
                    Amount   = "10.0",
                    Currency = "EUR"
                }
            };
            var storedOptions = new Tokenio.Proto.Common.TokenProtos.TokenRequestOptions
            {
                BankId           = "iron",
                ReceiptRequested = false
            };

            Assert.Throws <AggregateException>(() => member.StoreTokenRequestBlocking(storedPayload, storedOptions));
        }
Exemplo n.º 3
0
        public void AddAndGetAccessTokenRequest()
        {
            IList <ResourceType> types = new List <ResourceType>();

            types.Add(ResourceType.Accounts);
            var resourcesList = new ResourceTypeList();

            resourcesList.Resources.Add(types);
            var storedPayload = new TokenRequestPayload
            {
                UserRefId   = Util.Nonce(),
                RefId       = Util.Nonce(),
                RedirectUrl = Util.Nonce(),
                To          = new TokenMember
                {
                    Id = member.MemberId()
                },
                Description   = Util.Nonce(),
                CallbackState = Util.Nonce(),
                AccessBody    = new TokenRequestPayload.Types.AccessBody
                {
                    Type             = { types },
                    ResourceTypeList = resourcesList,
                }
            };

            var storedOptions = new Tokenio.Proto.Common.TokenProtos.TokenRequestOptions
            {
                BankId           = "iron",
                ReceiptRequested = false
            };

            var requestId = member.StoreTokenRequestBlocking(storedPayload, storedOptions);

            Assert.NotEmpty(requestId);

            var retrievedRequest = tokenClient.RetrieveTokenRequestBlocking(requestId);

            Assert.Equal(storedPayload, retrievedRequest.GetTokenRequestPayload());
            Assert.Equal(storedOptions, retrievedRequest.GetTokenRequestOptions());
        }