Exemplo n.º 1
0
        public static RecurlySubscription GetSubscriptionResult(string resultKey)
        {
            RecurlySubscription subscription = new RecurlySubscription(new RecurlyAccount(String.Empty));
            HttpStatusCode      statusCode   = GetResult(resultKey, new RecurlyClient.ReadXmlDelegate(subscription.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
            {
                return(null);
            }

            return(subscription);
        }
        public static RecurlySubscription Get(RecurlyAccount account)
        {
            RecurlySubscription sub = new RecurlySubscription(account);

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     SubscriptionUrl(account.AccountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(sub.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
            {
                return(null);
            }

            return(sub);
        }
        public static RecurlySubscription Get(RecurlyAccount account)
        {
            RecurlySubscription sub = new RecurlySubscription(account);

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                SubscriptionUrl(account.AccountCode),
                new RecurlyClient.ReadXmlDelegate(sub.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
                return null;

            return sub;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Returns a list of subscriptions for an account.
 /// </summary>
 /// <param name="state"></param>
 /// <param name="pageSize"></param>
 /// <returns></returns>
 public RecurlySubscriptionList ListSubscriptions(RecurlySubscription.SubscriptionState state = RecurlySubscription.SubscriptionState.Live, int pageSize = RecurlyPager.DefaultPageSize)
 {
     return RecurlySubscriptionList.GetAccountSubscriptions(AccountCode, state, pageSize);
 }
 internal static void ProcessElement(XElement element, RecurlySubscription sub)
 {
     switch(element.Name.LocalName)
     {
         case NetTermsElement:
             if(sub.ManualInvoiceDetails == null)
                 sub.ManualInvoiceDetails = new RecurlyManualInvoiceDetails();
             sub.ManualInvoiceDetails.NetTerms = element.ToInt();
             break;
         case PurchaseOrderNumberElement:
             if(sub.ManualInvoiceDetails == null)
                 sub.ManualInvoiceDetails = new RecurlyManualInvoiceDetails();
             sub.ManualInvoiceDetails.PurchaseOrderNumber = element.Value;
             break;
     }
 }
        protected override void ReadElement(XElement element)
        {
            element.ProcessChild(AccountCodeElement, e =>
                AccountCode = e.GetHrefLinkId());

            element.ProcessDescendant(PlanCodeElement, e =>
                PlanCode = e.Value);

            element.ProcessChild(IdElement, e =>
                Id = e.Value);

            element.ProcessChild(StateElement, e =>
                State = e.ToEnum<SubscriptionState>());

            element.ProcessChild(UnitAmountInCentsElement, e =>
                UnitAmountInCents = e.ToInt());

            element.ProcessChild(CurrencyElement, e =>
                Currency = e.Value);

            element.ProcessChild(QuantityElement, e =>
                Quantity = e.ToInt());

            element.ProcessChild(ActivatedAtElement, e =>
                ActivatedAt = e.ToDateTime());

            element.ProcessChild(CanceledAtElement, e =>
                CanceledAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(ExpiresAtElement, e =>
                ExpiresAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(CurrentPeriodStartedAtElement, e =>
                CurrentPeriodStartedAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(CurrentPeriodEndsAtElement, e =>
                CurrentPeriodEndsAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(TrialStartedAtElement, e =>
                TrialStartedAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(TrialEndsAtElement, e =>
                _trialEndsAt = e.ToNullable(DateTime.Parse));

            element.ProcessChild(CollectionMethodElement, e =>
                CollectionMethod = e.ToEnum<CollectionMethods>());

            element.ProcessChild(RecurlySubscriptionAddon.ElementName, e =>
                Addons.Add(new RecurlySubscriptionAddon(e)));

            element.ProcessChild(PendingSubscriptionElement, e =>
                PendingSubscription = new RecurlySubscription(e));

            RecurlyManualInvoiceDetails.ProcessElement(element, this);
        }
        /// <summary>
        /// Lookup a subscription's details.
        /// </summary>
        /// <param name="subscriptionId"></param>
        /// <returns></returns>
        public static RecurlySubscription Get(string subscriptionId)
        {
            var sub = new RecurlySubscription();
            var statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                          String.Format(Settings.Default.PathSubscriptionGet,
                                                                        subscriptionId),
                                                          sub.ReadXml);

            return statusCode == HttpStatusCode.NotFound ? null : sub;
        }