private static string validateTokenRequest(TokenRequest request)
        {
            StringBuilder validationErrors = new StringBuilder();
            if (request.CardNumber == null)
            {
                validationErrors.Append("CardNumber is required.\n");
            }
            if (request.ExpiryDateMMYY == null)
            {
                validationErrors.Append("ExpiryDateMMYY is required.\n");
            }

            if (validationErrors.Length == 0)
            {
                return null;
            }
            else
            {
                return validationErrors.ToString();
            }
        }
 internal HpEcommerce.messages.Token sendPutToken(TokenRequest request, string token)
 {
     HttpWebResponse response = client.sendPutRequest(UrlGenerator.getTokenizationUrl(CardAcceptor, token, Environment), HpXmlSerializer.getMessage(typeof(TokenRequest), request), SharedSecret);
     if (response.StatusCode == HttpStatusCode.Created)
     {
         return HpXmlSerializer.convertToken(getResponsestring(response));
     }
     else
     {
         throw new HpServerError("PUT (create) token failed.", HpXmlSerializer.convertErrorMessage(getResponsestring(response)));
     }
 }
 internal static TokenRequest tokenRequest(string cardNumber, string expiryDateMMYY)
 {
     TokenRequest tokenRequest = new TokenRequest();
     tokenRequest.CardNumber = cardNumber;
     tokenRequest.ExpiryDateMMYY = expiryDateMMYY;
     string validationErrors = validateTokenRequest(tokenRequest);
     if (validationErrors != null)
     {
         throw new HpECommerceException("Message failed validation \n" + validationErrors);
     }
     return tokenRequest;
 }