/// <summary> /// Creates a new Account. Access is restricted to an API account with create merchant privileges. /// </summary> /// <param name="createAccount">An XML request to create an account</param> /// <returns>An Account object</returns> public Account CreateAccount(CreateAccount createAccount) { Account result = null; Uri uri = new Uri(this.EndPoint.AbsoluteUri + "api/account/create"); HttpWebRequest request = this.CreateRequestPOST(uri, createAccount); using (HttpWebResponse response = request.GetResponseWithoutException() as HttpWebResponse) { if (response.StatusCode == HttpStatusCode.Created) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { XDocument document = XDocument.Load(reader); result = new Account(document.Element("Account")); } } else { this.HandleError(response); } } return result; }
/// <summary> /// This method contains a series of common asserts for the Create Account method. /// </summary> /// <param name="account">The Account object</param> /// <param name="merchantID">Merchant system account ID.</param> /// <param name="email">Email address of the primary user.</param> /// <param name="firstName">First name of the primary user (optional).</param> /// <param name="lastName">Last name of the primary user (optional).</param> /// <param name="company">Merchant Company.</param> /// <param name="country">Country that the merchant is headquartered in. ISO 3166-1 2 character country code.</param> private static void CreateAccountCommonAsserts(Account account, String merchantID, String email, String firstName, String lastName, String company, String country) { Assert.IsNotNull(account.MerchantID); Assert.AreEqual(merchantID, account.MerchantID); Assert.AreEqual(email, account.Email); Assert.AreEqual(firstName, account.FirstName); Assert.AreEqual(lastName, account.LastName); Assert.AreEqual(company, account.CompanyName); Assert.AreEqual(country, account.Country); Assert.AreEqual(20, account.AccessKeyID.Length); Assert.AreEqual(40, account.SecretAccessKey.Length); }