/// <summary>
        /// Retrieve a profile using the profile's ID. If you want to modify a profile
        /// you must first retrieve it using this method.
        /// </summary>
        /// <returns>The profile.</returns>
        /// <param name="profileId">Profile identifier.</param>
        public PaymentProfile GetProfile(string profileId)
        {
            string url = BeanstreamUrls.BaseProfilesUrl
                         .Replace("{v}", String.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                         .Replace("{p}", String.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                         + "/" + profileId;


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

            string         response = req.ProcessTransaction(HttpMethod.Get, url);
            PaymentProfile profile  = JsonConvert.DeserializeObject <PaymentProfile>(response);

            profile.Id = profileId;
            return(profile);
        }
Beispiel #2
0
        /// <summary>
        /// Updates the profile. You must first retrieve the profile using ProfilesAPI.GetProfile(id)
        /// </summary>
        /// <returns>The profile response.</returns>
        /// <param name="profile">Profile.</param>
        public ProfileResponse UpdateProfile(PaymentProfile profile)
        {
            var url = BeanstreamUrls.ProfileUrl
                      .Replace("{v}", string.IsNullOrEmpty(_configuration.Version) ? "v1" : "v" + _configuration.Version)
                      .Replace("{p}", string.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                      .Replace("{pid}", profile.Id);

            var req = CreateWebRequest();

            var updateProfile = new
            {
                billing  = profile.Billing,
                custom   = profile.CustomFields,
                language = profile.Language,
                comment  = profile.Comment
            };

            var response = req.ProcessTransaction(HttpMethod.Put, url, updateProfile);

            return(JsonConvert.DeserializeObject <ProfileResponse>(response));
        }
        /// <summary>
        /// Updates the profile. You must first retrieve the profile using ProfilesAPI.GetProfile(id)
        /// </summary>
        /// <returns>The profile response.</returns>
        /// <param name="profile">Profile.</param>
        public ProfileResponse UpdateProfile(PaymentProfile profile)
        {
            string url = BeanstreamUrls.BaseProfilesUrl
                .Replace("{v}", String.IsNullOrEmpty(_configuration.Version) ? "v1" : "v"+_configuration.Version)
                .Replace("{p}", String.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform)
                +"/"+profile.Id;

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

            var updateProfile = new {

                billing = profile.Billing,
                custom = profile.CustomFields,
                language = profile.Language,
                comment = profile.Comment
            };

            string response = req.ProcessTransaction (HttpMethod.Put, url, updateProfile);
            return JsonConvert.DeserializeObject<ProfileResponse>(response);
        }