コード例 #1
0
        /// <summary>
        /// Atualizar Cartão do Assinante - Update Subscriber Card
        /// </summary>
        /// <param name="body"></param>
        /// <param name="code"> Código do Assinante </param>
        /// <returns></returns>
        public async Task <SubscriberResponse> UpdateSubscriberCard(SubscriberRequest body, string code)
        {
            string json;

            try
            {
                json = JsonConvert.SerializeObject(body);
                JObject jObject = JObject.Parse(json);
                json = jObject["billing_info"].ToString();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            StringContent       stringContent = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/customers/{code}/billing_infos", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            try
            {
                return(JsonConvert.DeserializeObject <SubscriberResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        /// <summary>
        /// Alterar Assinante - Change Subscriber
        /// </summary>
        /// <param name="body"></param>
        /// <param name="code"> Código do Assinante </param>
        /// <returns></returns>
        public async Task <HttpStatusCode> ChangeSubscriber(SubscriberRequest body, string code)
        {
            string json;

            try
            {
                json = JsonConvert.SerializeObject(body);
                JObject jObject = JObject.Parse(json);
                jObject["address"]["streetNumber"].Rename("number");
                jObject["address"]["zipCode"].Rename("zipcode");
                json = jObject.ToString();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            StringContent       stringContent = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/customers/{code}", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            return(response.StatusCode);
        }
コード例 #3
0
        /// <summary>
        /// Alterar método de pagamento - Change Payment Method
        /// </summary>
        /// <param name="body"></param>
        /// <param name="code"> Código do Assinante </param>
        /// <returns></returns>
        public async Task <HttpStatusCode> ChangePaymentMethod(SubscriptionRequest body, string code)
        {
            StringContent       stringContent = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/subscriptions/{code}/change_payment_method", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            return(response.StatusCode);
        }
コード例 #4
0
        /// <summary>
        /// Reativar Assinatura - Reactivate Signature
        /// </summary>
        /// <param name="code">Código da Assinatura</param>
        /// <returns></returns>
        public async Task <HttpStatusCode> ReactivateSignature(string code)
        {
            StringContent       stringContent = new StringContent(JsonConvert.SerializeObject(null), Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/subscriptions/{code}/activate", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            return(response.StatusCode);
        }
コード例 #5
0
        /// <summary>
        /// Ativar ou Inativar Cupon - Enable or Disable Coupon
        /// </summary>
        /// <param name="code">Código do Cupom</param>
        /// <param name="active_or_inactive">Escolha active para Ativar um Cupom e inactive para desativar</param>
        /// <returns></returns>
        public async Task <CouponResponse> EnableOrDisableCoupon(string code, string active_or_inactive)
        {
            StringContent       stringContent = new StringContent(JsonConvert.SerializeObject(null), Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/coupons/{code}/{active_or_inactive}", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            try
            {
                return(JsonConvert.DeserializeObject <CouponResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        /// <summary>
        /// Associar Cupom para Assinatura Existente - Associate Coupon For Existing Signature
        /// </summary>
        /// <returns></returns>
        public async Task <CouponResponse> AssociateCouponForExistingSignature(CouponRequest body, string code)
        {
            StringContent       stringContent = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await ClientInstance.PutAsync($"assinaturas/v1/subscriptions/{code}", stringContent);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            try
            {
                return(JsonConvert.DeserializeObject <CouponResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }