public void When_I_update_an_AHC_bank_account_Then_it_should_be_updated_sync()
        {
            _profile = _service.Create(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = _service.Create(address);

            AchBankAccounts account = SampleFactory.CreatSampleAchBankAccount(_profile, address);

            account = _service.Create(account);

            var newAccountHolderName = "Foo";

            account.AccountHolderName(newAccountHolderName);

            _service.Update(account);

            var returnedAccount = _service.Get(AchBankAccounts.Builder()
                                               .Id(account.Id())
                                               .ProfileId(_profile.Id())
                                               .Build());

            Assert.That(returnedAccount.AccountHolderName(), Is.EqualTo(newAccountHolderName));

            _service.Delete(account);
        }
Пример #2
0
        /// <summary>
        /// update Profile
        /// </summary>
        /// <param name="profile">Profile</param>
        /// <returns>Profile</returns>
        public Profile Update(Profile profile)
        {
            profile.SetRequiredFields(new List <string> {
                GlobalConstants.Id
            });
            profile.CheckRequiredFields();
            profile.SetRequiredFields(new List <string> {
                GlobalConstants.MerchantCustomerId,
                GlobalConstants.Locale
            });
            profile.SetOptionalFields(new List <string> {
                GlobalConstants.FirstName,
                GlobalConstants.MiddleName,
                GlobalConstants.LastName,
                GlobalConstants.DateOfBirth,
                GlobalConstants.Ip,
                GlobalConstants.Gender,
                GlobalConstants.Nationality,
                GlobalConstants.Email,
                GlobalConstants.Phone,
                GlobalConstants.CellPhone
            });

            Request request = new Request(
                method: RequestType.Put,
                uri: PrepareUri("/profiles/" + profile.Id()),
                body: profile
                );

            dynamic response = _client.ProcessRequest(request);

            return(new Profile(response));
        }
        public async Task When_I_update_an_EFT_bank_account_Then_it_should_be_updated_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = await _service.CreateAsync(address);

            EftBankAccounts account = SampleFactory.CreatSampleEftBankAccount(_profile, address);

            account = await _service.CreateAsync(account);

            var newAccountHolderName = "Foo";

            account.AccountHolderName(newAccountHolderName);

            await _service.UpdateAsync(account);

            var returnedAccount = await _service.GetAsync(EftBankAccounts.Builder()
                                                          .Id(account.Id())
                                                          .ProfileId(_profile.Id())
                                                          .BillingAddressId(address.Id())
                                                          .Build());

            Assert.That(returnedAccount.AccountHolderName(), Is.EqualTo(newAccountHolderName));

            await _service.DeleteAsync(account);
        }
        public async Task When_I_lookup_a_profile_using_a_profile_id_Then_it_should_return_a_valid_profile_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var returnedProfile = await _service.GetAsync(Profile.Builder()
                                                          .Id(_profile.Id())
                                                          .Build());

            Assert.That(ProfilesAreEquivalent(_profile, returnedProfile));
        }
Пример #5
0
 public static Card CreateSampleCard(Profile profile, Address address)
 {
     return(Card.Builder()
            .ProfileId(profile.Id())
            .CardNum("4111111111111111")
            .CardExpiry()
            .Month(DateTime.Now.Month)
            .Year(DateTime.Now.AddYears(1).Year)
            .Done()
            .BillingAddressId(address.Id())
            .Build());
 }
        /*
         * Helpers
         */

        private bool ProfilesAreEquivalent(Profile profile1, Profile profile2)
        {
            if (!profile1.Id().Equals(profile2.Id()) ||
                !profile1.Phone().Equals(profile2.Phone()) ||
                !profile1.FirstName().Equals(profile2.FirstName()) ||
                !profile1.LastName().Equals(profile2.LastName()) ||
                !profile1.Email().Equals(profile2.Email()))
            {
                return(false);
            }

            return(true);
        }
        public void When_I_lookup_an_address_Then_it_should_return_a_valid_address_sync()
        {
            _profile = _service.Create(_profile);
            var address = SampleFactory.CreateSampleAddress(_profile);

            address = _service.Create(address);

            var returnedAddress = _service.Get(Address.Builder()
                                               .Id(address.Id())
                                               .ProfileId(_profile.Id())
                                               .Build());

            Assert.That(AddressesAreEquivalent(address, returnedAddress));
        }
        public void When_I_lookup_a_card_Then_it_should_return_a_valid_card_sync()
        {
            _profile = _service.Create(_profile);
            var card = SampleFactory.CreateSampleCard(_profile);

            card = _service.Create(card);

            var returnedCard = _service.Get(Card.Builder()
                                            .Id(card.Id())
                                            .ProfileId(_profile.Id())
                                            .Build());

            Assert.That(CardsAreEquivalent(card, returnedCard));
        }
Пример #9
0
        public static EftBankAccounts CreatSampleEftBankAccount(Profile profile, Address address)
        {
            long accountNumber = LongRandom(1000, 999999999999);

            return(EftBankAccounts.Builder()
                   .MerchantRefNum(Guid.NewGuid().ToString())
                   .NickName("Sally Barclays Account")
                   .AccountNumber(accountNumber.ToString())
                   .AccountHolderName("XYZ Business")
                   .BillingAddressId(address.Id())
                   .ProfileId(profile.Id())
                   .TransitNumber("00000")
                   .InstitutionId("123")
                   .Build());
        }
Пример #10
0
        public static AchBankAccounts CreatSampleAchBankAccount(Profile profile, Address address)
        {
            long accountNumber = LongRandom(1000, 99999999999999999);

            return(AchBankAccounts.Builder()
                   .MerchantRefNum(Guid.NewGuid().ToString())
                   .NickName("Sally Barclays Account")
                   .AccountType("CHECKING")
                   .AccountNumber(accountNumber.ToString())
                   .AccountHolderName("XYZ Business")
                   .RoutingNumber("122000661")
                   .BillingAddressId(address.Id())
                   .ProfileId(profile.Id())
                   .Build());
        }
Пример #11
0
 public static Address CreateSampleAddress(Profile profile)
 {
     return(Address.Builder()
            .ProfileId(profile.Id())
            .NickName("home")
            .Street("100 Queen Street West")
            .Street2("Unit 201")
            .City("Toronto")
            .Country("CA")
            .State("ON")
            .Zip("M5H 2N2")
            .RecipientName("Jane Doe")
            .Phone("647-788-3901")
            .Build());
 }
Пример #12
0
        /// <summary>
        /// delete profile
        /// </summary>
        /// <param name="profile">Profile</param>
        /// <returns>bool</returns>
        public bool Delete(Profile profile)
        {
            profile.SetRequiredFields(new List <string> {
                GlobalConstants.Id
            });
            profile.CheckRequiredFields();

            Request request = new Request(
                method: RequestType.Delete,
                uri: PrepareUri("/profiles/" + profile.Id())
                );

            _client.ProcessRequest(request);

            return(true);
        }
Пример #13
0
 public static Card CreateSampleCard(Profile profile)
 {
     return(Card.Builder()
            .ProfileId(profile.Id())
            .CardNum("4111111111111111")
            .CardExpiry()
            .Month(DateTime.Now.Month)
            .Year(DateTime.Now.AddYears(1).Year)
            .Done()
            .BillingAddress()
            .Street("100 Queen Street West")
            .City("Toronto")
            .State("ON")
            .Country("CA")
            .Zip("M5H2N2")
            .Done()
            .Build());
 }
        public void When_I_lookup_an_EFT_bank_account_Then_it_should_return_a_valid_EFT_bank_account_sync()
        {
            _profile = _service.Create(_profile);
            var address = SampleFactory.CreateSampleAddress(_profile);

            address = _service.Create(address);
            EftBankAccounts account = SampleFactory.CreatSampleEftBankAccount(_profile, address);

            account = _service.Create(account);

            var returnedAccount = _service.Get(EftBankAccounts.Builder()
                                               .Id(account.Id())
                                               .ProfileId(_profile.Id())
                                               .BillingAddressId(address.Id())
                                               .Build());

            Assert.That(EftBankAccountsAreEquivalent(account, returnedAccount));

            _service.Delete(account);
        }
        public async Task When_I_lookup_an_AHC_bank_account_Then_it_should_return_a_valid_AHC_bank_account_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = await _service.CreateAsync(address);

            AchBankAccounts account = SampleFactory.CreatSampleAchBankAccount(_profile, address);

            account = await _service.CreateAsync(account);

            var returnedAccount = await _service.GetAsync(AchBankAccounts.Builder()
                                                          .Id(account.Id())
                                                          .ProfileId(_profile.Id())
                                                          .Build());

            Assert.That(AchBankAccountsAreEquivalent(account, returnedAccount));

            await _service.DeleteAsync(account);
        }
        public void When_I_delete_a_card_Then_it_should_be_deleted_sync()
        {
            _profile = _service.Create(_profile);

            var card = SampleFactory.CreateSampleCard(_profile);

            card = _service.Create(card);

            _service.Delete(card);

            Assert.Throws <Paysafe.Common.EntityNotFoundException>(() => _service.Get(Card.Builder()
                                                                                      .Id(card.Id())
                                                                                      .ProfileId(_profile.Id())
                                                                                      .Build()));
        }
        public void When_I_delete_a_profile_Then_it_should_be_deleted_sync()
        {
            _profile = _service.Create(_profile);

            _service.Delete(_profile);

            Assert.Throws <Paysafe.Common.EntityNotFoundException>(() => _service.Get(Profile.Builder()
                                                                                      .Id(_profile.Id())
                                                                                      .Build()));
        }
        public async Task When_I_delete_a_profile_Then_it_should_be_deleted_async()
        {
            _profile = await _service.CreateAsync(_profile);

            await _service.DeleteAsync(_profile);

            Assert.ThrowsAsync <Paysafe.Common.EntityNotFoundException>(async() => await _service.GetAsync(Profile.Builder()
                                                                                                           .Id(_profile.Id())
                                                                                                           .Build()));
        }
        public async Task When_I_delete_an_EFT_bank_account_Then_it_should_be_deleted_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = await _service.CreateAsync(address);

            EftBankAccounts account = SampleFactory.CreatSampleEftBankAccount(_profile, address);

            account = await _service.CreateAsync(account);

            var response = await _service.DeleteAsync(account);

            Assert.That(response, Is.True);
            Assert.ThrowsAsync <Paysafe.Common.EntityNotFoundException>(async() => await _service.GetAsync(EftBankAccounts.Builder()
                                                                                                           .Id(account.Id())
                                                                                                           .ProfileId(_profile.Id())
                                                                                                           .BillingAddressId(address.Id())
                                                                                                           .Build()));
        }
        public void When_I_delete_an_address_Then_it_should_be_deleted_sync()
        {
            _profile = _service.Create(_profile);
            var address = SampleFactory.CreateSampleAddress(_profile);

            address = _service.Create(address);

            _service.Delete(address);

            Assert.Throws <Paysafe.Common.EntityNotFoundException>(() => _service.Get(Address.Builder()
                                                                                      .Id(address.Id())
                                                                                      .ProfileId(_profile.Id())
                                                                                      .Build()));
        }
        public void When_I_delete_an_AHC_bank_account_Then_it_should_be_deleted_sync()
        {
            _profile = _service.Create(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = _service.Create(address);

            AchBankAccounts account = SampleFactory.CreatSampleAchBankAccount(_profile, address);

            account = _service.Create(account);

            var response = _service.Delete(account);

            Assert.That(response, Is.True);
            Assert.Throws <Paysafe.Common.EntityNotFoundException>(() => _service.Get(AchBankAccounts.Builder()
                                                                                      .Id(account.Id())
                                                                                      .ProfileId(_profile.Id())
                                                                                      .Build()));
        }
        public async Task When_I_delete_an_address_Then_it_should_be_deleted_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var address = SampleFactory.CreateSampleAddress(_profile);

            address = await _service.CreateAsync(address);

            await _service.DeleteAsync(address);

            Assert.ThrowsAsync <Paysafe.Common.EntityNotFoundException>(async() => await _service.GetAsync(Address.Builder()
                                                                                                           .Id(address.Id())
                                                                                                           .ProfileId(_profile.Id())
                                                                                                           .Build()));
        }
Пример #23
0
        /// <summary>
        /// get profile with subcomponents
        /// </summary>
        /// <param name="profile">Profile</param>
        /// <returns>Profile</returns>
        public Profile Get(Profile profile, bool includeAddresses = false, bool includeCards           = false, bool includeAchBankAccounts  = false,
                           bool includeBacsBankAccounts           = false, bool includeEftBankAccounts = false, bool includeSepaBankAccounts = false)
        {
            profile.SetRequiredFields(new List <string> {
                GlobalConstants.Id
            });
            profile.CheckRequiredFields();

            Dictionary <string, string> queryStr = new Dictionary <string, string>();
            StringBuilder toInclude = new StringBuilder();

            if (includeAddresses)
            {
                toInclude.Append("addresses");
            }
            if (includeCards)
            {
                if (toInclude.Length > 0)
                {
                    toInclude.Append(",");
                }
                toInclude.Append("cards");
            }
            if (includeAchBankAccounts)
            {
                if (toInclude.Length > 0)
                {
                    toInclude.Append(",");
                }
                toInclude.Append("achbankaccounts");
            }
            if (includeBacsBankAccounts)
            {
                if (toInclude.Length > 0)
                {
                    toInclude.Append(",");
                }
                toInclude.Append("bacsbankaccounts");
            }
            if (includeEftBankAccounts)
            {
                if (toInclude.Length > 0)
                {
                    toInclude.Append(",");
                }
                toInclude.Append("eftbankaccounts");
            }
            if (includeSepaBankAccounts)
            {
                if (toInclude.Length > 0)
                {
                    toInclude.Append(",");
                }
                toInclude.Append("sepabankaccounts");
            }

            queryStr.Add("fields", toInclude.ToString());
            Request request = new Request(
                method: RequestType.Get,
                uri: PrepareUri("/profiles/" + profile.Id()),
                queryString: queryStr
                );

            dynamic response = _client.ProcessRequest(request);

            return(new Profile(response));
        }
        public async Task When_I_delete_a_card_Then_it_should_be_deleted_async()
        {
            _profile = await _service.CreateAsync(_profile);

            var card = SampleFactory.CreateSampleCard(_profile);

            card = await _service.CreateAsync(card);

            await _service.DeleteAsync(card);

            Assert.ThrowsAsync <Paysafe.Common.EntityNotFoundException>(async() => await _service.GetAsync(Card.Builder()
                                                                                                           .Id(card.Id())
                                                                                                           .ProfileId(_profile.Id())
                                                                                                           .Build()));
        }