コード例 #1
0
        public Pager <T> FetchNextPage()
        {
            var pager = RecurlyClient.MakeRequest <Pager <T> >(Method.GET, Next, null, null, Options);

            this.Clone(pager);
            return(this);
        }
コード例 #2
0
 public void Create()
 {
     HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                                              SubscriptionUrl(this.Account.AccountCode),
                                                              new RecurlyClient.WriteXmlDelegate(WriteSubscriptionXml),
                                                              new RecurlyClient.ReadXmlDelegate(this.ReadXml));
 }
コード例 #3
0
        private static HttpStatusCode GetResult(string resultKey, RecurlyClient.ReadXmlDelegate readXmlDelegate)
        {
            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     ResultsUrlPrefix + System.Web.HttpUtility.UrlEncode(resultKey),
                                                                     readXmlDelegate);

            return(statusCode);
        }
コード例 #4
0
        public T First()
        {
            Dictionary <string, object> firstParams = new Dictionary <string, object>(QueryParams);

            firstParams["limit"] = 1;
            var firstUrl = NextUrl(firstParams);
            var pager    = RecurlyClient.MakeRequest <Pager <T> >(Method.GET, firstUrl, null, null, Options);

            return(pager.Data.FirstOrDefault());
        }
コード例 #5
0
        /// <summary>
        /// Immediately terminate the subscription and issue a refund.  The refund can be for the full amount
        /// or prorated until its paid-thru date.  If you need to refund a specific amount, please issue a
        /// refund against the individual transaction instead.
        /// </summary>
        /// <param name="accountCode">Subscriber's Account Code</param>
        /// <param name="refundType"></param>
        public static void RefundSubscription(string accountCode, RefundType refundType)
        {
            string refundTypeParameter = refundType.ToString().ToLower();

            string refundUrl = String.Format("{0}?refund={1}",
                                             SubscriptionUrl(accountCode),
                                             refundTypeParameter);

            RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete, refundUrl);
        }
コード例 #6
0
        public async Task <Pager <T> > FetchNextPageAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var task = RecurlyClient.MakeRequestAsync <Pager <T> >(Method.GET, Next, null, null, Options, cancellationToken);

            return(await task.ContinueWith(t =>
            {
                var pager = t.Result;
                this.Clone(pager);
                return this;
            }));
        }
コード例 #7
0
        /// <summary>
        /// Redeem a coupon on an account.
        /// </summary>
        /// <param name="accountCode"></param>
        /// <param name="couponCode"></param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Redeem(string accountCode, string couponCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();

            coupon.AccountCode = accountCode;
            coupon.CouponCode  = couponCode;

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                                                     CouponUrl(coupon.AccountCode),
                                                                     new RecurlyClient.WriteXmlDelegate(coupon.WriteXml),
                                                                     new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

            return(coupon);
        }
コード例 #8
0
        public static RecurlyTransaction[] GetTransactions(string accountCode)
        {
            RecurlyTransactionList transactionList = new RecurlyTransactionList();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     RecurlyTransaction.TransactionsUrl(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(transactionList.ReadXml));

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

            return(transactionList.ToArray());
        }
コード例 #9
0
        /// <summary>
        /// Lookup a Recurly account
        /// </summary>
        /// <param name="accountCode"></param>
        /// <returns></returns>
        public static RecurlyAccount Get(string accountCode)
        {
            RecurlyAccount account = new RecurlyAccount();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     UrlPrefix + System.Web.HttpUtility.UrlEncode(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(account.ReadXml));

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

            return(account);
        }
コード例 #10
0
        public static RecurlyTransaction Get(string transactionId)
        {
            RecurlyTransaction transaction = new RecurlyTransaction();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     UrlPrefix + System.Web.HttpUtility.UrlEncode(transactionId),
                                                                     new RecurlyClient.ReadXmlDelegate(transaction.ReadXml));

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

            return(transaction);
        }
コード例 #11
0
        public static RecurlyInvoice[] GetInvoices(string accountCode, int pageNumber = 1)
        {
            RecurlyInvoiceList invoiceList = new RecurlyInvoiceList();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     AccountInvoicesUrl(accountCode, pageNumber),
                                                                     new RecurlyClient.ReadXmlDelegate(invoiceList.ReadXml));

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

            return(invoiceList.ToArray());
        }
コード例 #12
0
        public static RecurlyPlan Get(string planCode)
        {
            RecurlyPlan plan = new RecurlyPlan();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     UrlPrefix + System.Web.HttpUtility.UrlEncode(planCode),
                                                                     new RecurlyClient.ReadXmlDelegate(plan.ReadXml));

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

            return(plan);
        }
コード例 #13
0
        /// <summary>
        /// Look up a coupon for an account
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Get(string accountCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     CouponUrl(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

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

            return(coupon);
        }
コード例 #14
0
        /// <summary>
        /// Create an Invoice if there are outstanding charges on an account. If there are no outstanding
        /// charges, null is returned.
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyInvoice Create(string accountCode)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                                                     "/accounts/" + System.Web.HttpUtility.UrlEncode(accountCode) + UrlPrefix,
                                                                     new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

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

            return(invoice);
        }
コード例 #15
0
        /// <summary>
        /// Lookup a Recurly account's billing info
        /// </summary>
        /// <param name="accountCode"></param>
        /// <returns></returns>
        public static RecurlyBillingInfo Get(string accountCode)
        {
            RecurlyBillingInfo billingInfo = new RecurlyBillingInfo();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     BillingInfoUrl(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(billingInfo.ReadXml));

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

            return(billingInfo);
        }
コード例 #16
0
        /// <summary>
        /// Look up an Invoice.
        /// </summary>
        /// <param name="invoiceId">Invoice ID</param>
        /// <returns></returns>
        public static RecurlyInvoice Get(string invoiceId)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     UrlPrefix + System.Web.HttpUtility.UrlEncode(invoiceId),
                                                                     new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

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

            return(invoice);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        public static RecurlyLineItem[] GetCredits(string accountCode)
        {
            RecurlyLineItemList creditList = new RecurlyLineItemList();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     RecurlyCredit.CreditsUrl(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(creditList.ReadXml));

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

            return(creditList.ToArray());
        }
コード例 #19
0
        public static RecurlyCharge ChargeAccount(string accountCode, int amountInCents, string description)
        {
            RecurlyCharge charge = new RecurlyCharge();

            charge.AmountInCents = amountInCents;
            charge.StartDate     = DateTime.UtcNow;
            charge.Description   = description;

            /* HttpStatusCode statusCode = */
            RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                         ChargesUrl(accountCode),
                                         new RecurlyClient.WriteXmlDelegate(charge.WriteXml),
                                         null);

            return(charge);
        }
コード例 #20
0
        public static RecurlyCredit CreditAccount(string accountCode, int amountInCents, int quantity, string description)
        {
            RecurlyCredit credit = new RecurlyCredit();

            credit.AmountInCents = amountInCents;
            credit.Quantity      = quantity;
            credit.StartDate     = DateTime.UtcNow;
            credit.Description   = description;

            /* HttpStatusCode statusCode = */
            RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                         CreditsUrl(accountCode),
                                         new RecurlyClient.WriteXmlDelegate(credit.WriteXml),
                                         null);

            return(credit);
        }
コード例 #21
0
        public void ChangeSubscription(ChangeTimeframe timeframe)
        {
            RecurlyClient.WriteXmlDelegate writeXmlDelegate;

            if (timeframe == ChangeTimeframe.Now)
            {
                writeXmlDelegate = new RecurlyClient.WriteXmlDelegate(WriteChangeSubscriptionNowXml);
            }
            else
            {
                writeXmlDelegate = new RecurlyClient.WriteXmlDelegate(WriteChangeSubscriptionAtRenewalXml);
            }

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Put,
                                                                     SubscriptionUrl(this.Account.AccountCode),
                                                                     writeXmlDelegate,
                                                                     new RecurlyClient.ReadXmlDelegate(this.ReadXml));
        }
コード例 #22
0
 /// <summary>
 /// Remove the active coupon on an account.
 /// </summary>
 /// <param name="accountCode">Account code</param>
 public static void RemoveCoupon(string accountCode)
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete, CouponUrl(accountCode));
 }
コード例 #23
0
 /// <summary>
 /// Delete an account's billing info.
 /// </summary>
 public void ClearBillingInfo()
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete,
                                  BillingInfoUrl(this.AccountCode));
 }
コード例 #24
0
 /// <summary>
 /// Update an account's billing info in Recurly
 /// </summary>
 public void Update()
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Put,
                                  BillingInfoUrl(this.AccountCode),
                                  new RecurlyClient.WriteXmlDelegate(this.WriteXml));
 }
コード例 #25
0
 /// <summary>
 /// Close the account and cancel any active subscriptions (if there is one).
 /// Note: This does not create a refund for any time remaining.
 /// </summary>
 /// <param name="id">Account Code</param>
 public static void CloseAccount(string accountCode)
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete, UrlPrefix + System.Web.HttpUtility.UrlEncode(accountCode));
 }
コード例 #26
0
 /// <summary>
 /// Reactivate a canceled subscription.  The subscription will renew at the end of its current term.
 /// </summary>
 /// <param name="accountCode">Subscriber's Account Code</param>
 public static void ReactivateSubscription(string accountCode)
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post, SubscriptionUrl(accountCode) + "/reactivate");
 }
コード例 #27
0
 /// <summary>
 /// Cancel an active subscription.  The subscription will not renew, but will continue to be active
 /// through the remainder of the current term.
 /// </summary>
 /// <param name="accountCode">Subscriber's Account Code</param>
 public static void CancelSubscription(string accountCode)
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete, SubscriptionUrl(accountCode));
 }
コード例 #28
0
 /// <summary>
 /// Create a new account in Recurly
 /// </summary>
 public void Create()
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                  UrlPrefix,
                                  new RecurlyClient.WriteXmlDelegate(this.WriteXml));
 }
コード例 #29
0
 /// <summary>
 /// Update an existing account in Recurly
 /// </summary>
 public void Update()
 {
     RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Put,
                                  UrlPrefix + System.Web.HttpUtility.UrlEncode(this.AccountCode),
                                  new RecurlyClient.WriteXmlDelegate(this.WriteXml));
 }
コード例 #30
0
 private static string Url(string urlFormat)
 {
     return(RecurlyClient.ServerUrl(Configuration.RecurlySection.Current.Environment) +
            String.Format(urlFormat, Configuration.RecurlySection.Current.Subdomain));
 }