private ProfileResponse CreateProfile(Token token, Card card, Address billingAddress, CustomFields customFields, string language, string comment)
        {
            if (token == null && card == null) {
                Gateway.ThrowIfNullArgument (null, "Card and Token both null!");
            }

            if (token == null) {
                Gateway.ThrowIfNullArgument (card, "card");
                Gateway.ThrowIfNullArgument (card.Number, "card.number");
                Gateway.ThrowIfNullArgument (card.Name, "card.name");
                Gateway.ThrowIfNullArgument (card.ExpiryMonth, "card.expiryMonth");
                Gateway.ThrowIfNullArgument (card.ExpiryYear, "card.expiryYear");
            }
            if (card == null) {
                Gateway.ThrowIfNullArgument (token, "token");
                Gateway.ThrowIfNullArgument (token.Name, "token.name");
                Gateway.ThrowIfNullArgument (token.Code, "token.code");
            }

            string url = BeanstreamUrls.BaseProfilesUrl
                .Replace ("{v}", String.IsNullOrEmpty (_configuration.Version) ? "v1" : "v" + _configuration.Version)
                .Replace ("{p}", String.IsNullOrEmpty (_configuration.Platform) ? "www" : _configuration.Platform);

            HttpsWebRequest req = new HttpsWebRequest () {
                MerchantId = _configuration.MerchantId,
                Passcode = _configuration.ProfilesApiPasscode,
                WebCommandExecutor = _webCommandExecuter
            };

            var profile = new {
                card = card,
                token = token,
                billing = billingAddress,
                custom = customFields
            };

            string response = req.ProcessTransaction (HttpMethod.Post, url, profile);

            return JsonConvert.DeserializeObject<ProfileResponse>(response);
        }
 /// <summary>
 /// Create a Payment Profile with a single-use Legato token.
 /// </summary>
 /// <returns>TThe profile response containing the profile ID</returns>
 /// <param name="token">Token.</param>
 /// <param name="billingAddress">Billing address.</param>
 /// <param name="customFields">Custom fields. Optional</param>
 /// <param name="language">Language. Optional</param>
 /// <param name="comment">Comment. Optional</param>
 public ProfileResponse CreateProfile(Token token, Address billingAddress, CustomFields customFields, string language, string comment)
 {
     return CreateProfile (token, null, billingAddress, customFields, language, comment);
 }
 /// <summary>
 /// Create a Payment Profile with a Credit Card and billing address
 /// </summary>
 /// <returns>The profile response containing the profile ID</returns>
 /// <param name="card">Card.</param>
 /// <param name="billingAddress">Billing address.</param>
 /// <param name="customFields">Custom fields. Optional</param>
 /// <param name="language">Language. Optional</param>
 /// <param name="comment">Comment. Optional</param>
 public ProfileResponse CreateProfile(Card card, Address billingAddress, CustomFields customFields, string language, string comment)
 {
     return CreateProfile (null, card, billingAddress, customFields, language, comment);
 }
 /// <summary>
 /// Create a Payment Profile with a single-use Legato token.
 /// </summary>
 /// <returns>TThe profile response containing the profile ID</returns>
 /// <param name="token">Token.</param>
 /// <param name="billingAddress">Billing address.</param>
 public ProfileResponse CreateProfile(Token token, Address billingAddress)
 {
     return CreateProfile (token, billingAddress, null, null, null);
 }
 /// <summary>
 /// Create a Payment Profile with a Credit Card and billing address
 /// </summary>
 /// <returns>The profile response containing the profile ID</returns>
 /// <param name="card">Card.</param>
 /// <param name="billingAddress">Billing address.</param>
 public ProfileResponse CreateProfile(Card card, Address billingAddress)
 {
     return CreateProfile (card, billingAddress, null, null, null);
 }