Exemple #1
0
        public void RevokeUserFromMerhant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest()
            {
                MerchantId = createdMerchant.Id,
                Email      = "*****@*****.**"
            });

            var merchantUsers = merchantService.GetMerchantUsers(new GetMerchantUsersRequest()
            {
                MerchantId = createdMerchant.Id,
                Limit      = 5
            });

            var revokeResponse = merchantService.RevokeUserFromMerchant(new RevokeUserFromMerchantRequest()
            {
                MerchantId = createdMerchant.Id,
                UserId     = merchantUsers.Content[0].Id
            });

            Assert.IsNull(revokeResponse.Content);
            Assert.IsFalse(revokeResponse.IsError);
            Assert.AreEqual(204, revokeResponse.ResponseCode);
        }
Exemple #2
0
        public void RevokeAppFromMerchant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;

            _appService.SetApiKey(createdApp.Key);

            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            AddAppToMerchantRequest addRequest = new AddAppToMerchantRequest()
            {
                MerchantId = merchant.Id,
                AppId      = createdApp.Id
            };

            merchantService.AddAppToMerchant(addRequest);
            var revokeResponse = merchantService.RevokeAppFromMerchant(new RevokeAppFromMerchantRequest()
            {
                MerchantId = merchant.Id,
                AppId      = createdApp.Id
            });

            Assert.IsNull(revokeResponse.Content);
            Assert.IsFalse(revokeResponse.IsError);
            Assert.AreEqual(204, revokeResponse.ResponseCode);
        }
Exemple #3
0
        public void CreateMerchant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            ApiResponse <Merchant> merchant = merchantService.CreateMerchant(_createMerchantRequest);

            Assert.AreEqual(201, merchant.ResponseCode);
            Assert.IsFalse(string.IsNullOrEmpty(merchant.Content.Id));
        }
Exemple #4
0
        public void GetMerchantApps_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;

            _appService.SetApiKey(createdApp.Key);

            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            for (int i = 0; i < 4; i++)
            {
                createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
                merchantService.AddAppToMerchant(new AddAppToMerchantRequest()
                {
                    MerchantId = merchant.Id,
                    AppId      = createdApp.Id
                });
            }

            ApiResponse <List <App> > appsResponse = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                Limit      = 3
            });

            Assert.AreEqual(3, appsResponse.Content.Count);

            var beforeApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                Before     = appsResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, beforeApps.Content.Count);

            var afterApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest()
            {
                MerchantId = merchant.Id,
                After      = appsResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, beforeApps.Content.Count);

            var firstAppsIds  = appsResponse.Content.Select(m => m.Id);
            var beforeAppsIds = beforeApps.Content.Select(m => m.Id);
            var afterAppsIds  = afterApps.Content.Select(m => m.Id);

            var beforeIntersection = firstAppsIds.Intersect(beforeAppsIds);
            var afterIntersection  = firstAppsIds.Intersect(afterAppsIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }
Exemple #5
0
        public void GetMerchantUsers_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            var createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            for (int i = 0; i < 5; i++)
            {
                merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest()
                {
                    MerchantId = createdMerchant.Id,
                    Email      = "test" + i.ToString() + "@example.com"
                });
            }

            ApiResponse <List <User> > usersResponse = merchantService.GetMerchantUsers(new GetMerchantUsersRequest()
            {
                MerchantId = createdMerchant.Id,
                Limit      = 3
            });

            Assert.AreEqual(3, usersResponse.Content.Count);

            var beforeUsers = merchantService.GetMerchantUsers(new GetMerchantUsersRequest()
            {
                MerchantId = createdMerchant.Id,
                Before     = usersResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, beforeUsers.Content.Count);

            var afterMerchants = merchantService.GetMerchantUsers(new GetMerchantUsersRequest()
            {
                MerchantId = createdMerchant.Id,
                After      = usersResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, beforeUsers.Content.Count);

            var firtUsersIds   = usersResponse.Content.Select(m => m.Id);
            var beforeUsersIds = beforeUsers.Content.Select(m => m.Id);
            var afterUsersIds  = afterMerchants.Content.Select(m => m.Id);

            var beforeIntersection = firtUsersIds.Intersect(beforeUsersIds);
            var afterIntersection  = firtUsersIds.Intersect(afterUsersIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }
Exemple #6
0
        public void SaveCard_Success()
        {
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(AppKey);
            var cardResponse = merchantService.SaveCard(new SaveCardRequest()
            {
                MerchantId = MerchantId, TransactionId = TransactionId
            });

            Assert.IsNotNull(cardResponse.Content.Id);
            Assert.IsNotNull(cardResponse.Content);
            Assert.IsFalse(cardResponse.IsError);
            Assert.AreEqual(201, cardResponse.ResponseCode);
        }
Exemple #7
0
        public void GetMerchants_WithoutPagination_Fails()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            ApiResponse <List <Merchant> > merchantsResponse = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id
            });

            Assert.IsTrue(merchantsResponse.IsError);
            Assert.IsNotNull(merchantsResponse.ErrorContent);
            Assert.AreEqual(400, merchantsResponse.ResponseCode);
        }
Exemple #8
0
        public void CreateMerchant_WhenMissingRequiredFields_Fails()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            ApiResponse <Merchant> response = merchantService.CreateMerchant(new CreateMerchantRequest()
            {
                Test = true
            });

            Assert.IsTrue(response.IsError);
            Assert.IsNotNull(response.ErrorContent);
            Assert.AreEqual(400, response.ResponseCode);
        }
Exemple #9
0
        public void InviteUserToMerhant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            var inviteResult = merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest()
            {
                MerchantId = createdMerchant.Id,
                Email      = "*****@*****.**"
            });

            Assert.IsNotNull(inviteResult.Content);
            Assert.IsFalse(inviteResult.IsError);
            Assert.AreEqual(201, inviteResult.ResponseCode);
        }
Exemple #10
0
        public void GetMerchants_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            for (int i = 0; i < 5; i++)
            {
                _createMerchantRequest.Name = "TestMerchant_" + DateTime.Now.Ticks.ToString();
                merchantService.CreateMerchant(_createMerchantRequest);
            }

            ApiResponse <List <Merchant> > merchantsResponse = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id,
                Limit = 3
            });

            Assert.AreEqual(3, merchantsResponse.Content.Count);

            var beforeMerchants = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId  = createdApp.Id,
                Before = merchantsResponse.Content[2].Id,
                Limit  = 2
            });

            Assert.AreEqual(2, beforeMerchants.Content.Count);

            var afterMerchants = merchantService.GetMerchants(new GetMerchantsRequest()
            {
                AppId = createdApp.Id,
                After = merchantsResponse.Content[2].Id,
                Limit = 2
            });

            Assert.AreEqual(2, beforeMerchants.Content.Count);

            var firstMerchantsIds  = merchantsResponse.Content.Select(m => m.Id);
            var beforeMerchantsIds = beforeMerchants.Content.Select(m => m.Id);
            var afterMerchantsIds  = afterMerchants.Content.Select(m => m.Id);

            var beforeIntersection = firstMerchantsIds.Intersect(beforeMerchantsIds);
            var afterIntersection  = firstMerchantsIds.Intersect(afterMerchantsIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }
        private string GetMerchantId(string appKey, string publicKey)
        {
            try
            {
                PaylikeAppService appService = new PaylikeAppService(appKey);
                Identity          app        = appService.GetCurrentApp().Content.Identity;
                List <Merchant>   merchants  = new PaylikeMerchantService(appKey).GetMerchants(new GetMerchantsRequest()
                {
                    AppId = app.Id,
                    Limit = int.MaxValue
                }).Content;

                var configuredMerchant = merchants.FirstOrDefault(m => m.Key == publicKey);

                return(configuredMerchant.Id);
            }
            catch (Exception ex)
            {
                return(string.Empty);
            }
        }
Exemple #12
0
        public void GetMerchantLines_Success()
        {
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(AppKey);

            ApiResponse <List <Line> > linesResponse = merchantService.GetMerchantLines(new GetMerchantLinesRequest()
            {
                MerchantId = MerchantId,
                Limit      = 3
            });

            Assert.AreEqual(3, linesResponse.Content.Count);

            var beforeLines = merchantService.GetMerchantLines(new GetMerchantLinesRequest()
            {
                MerchantId = MerchantId,
                Before     = linesResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, beforeLines.Content.Count);

            var afterLines = merchantService.GetMerchantLines(new GetMerchantLinesRequest()
            {
                MerchantId = MerchantId,
                After      = linesResponse.Content[2].Id,
                Limit      = 2
            });

            Assert.AreEqual(2, afterLines.Content.Count);

            var firstLinesIds  = linesResponse.Content.Select(m => m.Id);
            var beforeLinesIds = beforeLines.Content.Select(m => m.Id);
            var afterAppsIds   = afterLines.Content.Select(m => m.Id);

            var beforeIntersection = firstLinesIds.Intersect(beforeLinesIds);
            var afterIntersection  = firstLinesIds.Intersect(afterAppsIds);

            Assert.AreEqual(0, beforeIntersection.Count());
            Assert.AreEqual(2, afterIntersection.Count());
        }
Exemple #13
0
        public void UpdateMerchant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);
            Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            merchantService.UpdateMerchant(new UpdateMerchantRequest()
            {
                MerchantId = createdMerchant.Id,
                Email      = "*****@*****.**",
                Name       = "new_name",
                Descriptor = "newDesc"
            });

            Merchant gotMerchant = merchantService.GetMerchant(new GetMerchantRequest()
            {
                MerchantId = createdMerchant.Id
            }).Content;

            Assert.AreEqual(gotMerchant.Name, "new_name");
            Assert.AreEqual(gotMerchant.Email, "*****@*****.**");
            Assert.AreEqual(gotMerchant.Descriptor, "newDesc");
        }
Exemple #14
0
        public void GetMerchant_Success()
        {
            App createdApp = _appService.CreateApp(new CreateAppRequest()).Content;
            IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key);

            Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content;

            Merchant gotMerchant = merchantService.GetMerchant(new GetMerchantRequest()
            {
                MerchantId = createdMerchant.Id
            }).Content;


            Assert.AreEqual(gotMerchant.Name, createdMerchant.Name);
            Assert.AreEqual(gotMerchant.Currency, createdMerchant.Currency);
            Assert.AreEqual(gotMerchant.Test, createdMerchant.Test);
            Assert.AreEqual(gotMerchant.Email, createdMerchant.Email);
            Assert.AreEqual(gotMerchant.Website, createdMerchant.Website);
            Assert.AreEqual(gotMerchant.Descriptor, createdMerchant.Descriptor);
            Assert.AreEqual(gotMerchant.Company.Country, createdMerchant.Company.Country);
            Assert.AreEqual(gotMerchant.Company.Number, createdMerchant.Company.Number);
            Assert.AreEqual(gotMerchant.Bank.IBAN, createdMerchant.Bank.IBAN);
        }