public Pager <T> FetchNextPage() { var pager = RecurlyClient.MakeRequest <Pager <T> >(Method.GET, Next, null, null, Options); this.Clone(pager); return(this); }
public void Create() { HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post, SubscriptionUrl(this.Account.AccountCode), new RecurlyClient.WriteXmlDelegate(WriteSubscriptionXml), new RecurlyClient.ReadXmlDelegate(this.ReadXml)); }
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); }
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()); }
/// <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); }
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; })); }
/// <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); }
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()); }
/// <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); }
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); }
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()); }
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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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 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()); }
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); }
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); }
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)); }
/// <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)); }
/// <summary> /// Delete an account's billing info. /// </summary> public void ClearBillingInfo() { RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete, BillingInfoUrl(this.AccountCode)); }
/// <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)); }
/// <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)); }
/// <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"); }
/// <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)); }
/// <summary> /// Create a new account in Recurly /// </summary> public void Create() { RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post, UrlPrefix, new RecurlyClient.WriteXmlDelegate(this.WriteXml)); }
/// <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)); }
private static string Url(string urlFormat) { return(RecurlyClient.ServerUrl(Configuration.RecurlySection.Current.Environment) + String.Format(urlFormat, Configuration.RecurlySection.Current.Subdomain)); }