/// <summary> /// Creates a new account with required billing information /// </summary> /// <param name="accountCode"></param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="creditCardNumber"></param> /// <param name="expirationMonth"></param> /// <param name="expirationYear"></param> public Account(string accountCode, string firstName, string lastName, string creditCardNumber, int expirationMonth, int expirationYear) { this.AccountCode = accountCode; this._billingInfo = new BillingInfo(accountCode); this._billingInfo.FirstName = firstName; this._billingInfo.LastName = lastName; this._billingInfo.CreditCardNumber = creditCardNumber; this._billingInfo.ExpirationMonth = expirationMonth; this._billingInfo.ExpirationYear = expirationYear; }
public void UpdateBillingInfo() { string s = Factories.GetMockAccountName("Update Billing Info"); Account acct = new Account(s, "John","Doe", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year+2); acct.Create(); BillingInfo billingInfo = new BillingInfo(acct); billingInfo.FirstName = "Jane"; billingInfo.LastName = "Smith"; billingInfo.CreditCardNumber = "4111111111111111"; billingInfo.ExpirationMonth = DateTime.Now.AddMonths(3).Month; billingInfo.ExpirationYear = DateTime.Now.AddYears(3).Year; billingInfo.Update(); Account a = Account.Get(s); Assert.AreEqual(a.BillingInfo.FirstName, "Jane"); Assert.AreEqual(a.BillingInfo.LastName, "Smith"); Assert.AreEqual(a.BillingInfo.ExpirationMonth, DateTime.Now.AddMonths(3).Month); Assert.AreEqual(a.BillingInfo.ExpirationYear, DateTime.Now.AddYears(3).Year); }
/// <summary> /// Creates a new account with required billing information /// </summary> /// <param name="accountCode"></param> /// <param name="billingInfo"></param> public Account(string accountCode, BillingInfo billingInfo) { AccountCode = accountCode; _billingInfo = billingInfo; }
/// <summary> /// Delete an account's billing info. /// </summary> public void DeleteBillingInfo() { Client.Instance.PerformRequest(Client.HttpRequestMethod.Delete, UrlPrefix + Uri.EscapeUriString(AccountCode) + "/billing_info"); _billingInfo = null; }
public bool Equals(BillingInfo billingInfo) { return AccountCode == billingInfo.AccountCode; }
/// <summary> /// Lookup a Recurly account's billing info /// </summary> /// <param name="accountCode"></param> /// <returns></returns> public static BillingInfo Get(string accountCode) { var billingInfo = new BillingInfo(); var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get, BillingInfoUrl(accountCode), billingInfo.ReadXml); return statusCode == HttpStatusCode.NotFound ? null : billingInfo; }
/// <summary> /// Lookup a Recurly account's billing info /// </summary> /// <param name="accountCode"></param> /// <returns></returns> public static BillingInfo Get(string accountCode) { BillingInfo billingInfo = new BillingInfo(); HttpStatusCode statusCode = Client.PerformRequest(Client.HttpRequestMethod.Get, BillingInfoUrl(accountCode), new Client.ReadXmlDelegate(billingInfo.ReadXml)); if (statusCode == HttpStatusCode.NotFound) return null; return billingInfo; }
public bool Equals(BillingInfo billingInfo) { return(AccountCode == billingInfo.AccountCode); }
/// <summary> /// Delete an account's billing info. /// </summary> public void ClearBillingInfo() { Client.PerformRequest(Client.HttpRequestMethod.Delete, UrlPrefix + System.Uri.EscapeUriString(this.AccountCode) + "/billing_info"); this._billingInfo = null; }
internal void ReadXml(XmlTextReader reader, string xmlName) { while (reader.Read()) { if (reader.Name == xmlName && reader.NodeType == XmlNodeType.EndElement) { break; } if (reader.NodeType != XmlNodeType.Element) { continue; } DateTime dt; switch (reader.Name) { case "account_code": AccountCode = reader.ReadElementContentAsString(); break; case "billing_info": BillingInfo = new BillingInfo(reader); break; case "state": // TODO investigate in case of incoming data representing multiple states, as https://dev.recurly.com/docs/get-account says is possible State = reader.ReadElementContentAsString().ParseAsEnum <AccountState>(); break; case "username": Username = reader.ReadElementContentAsString(); break; case "email": Email = reader.ReadElementContentAsString(); break; case "first_name": FirstName = reader.ReadElementContentAsString(); break; case "last_name": LastName = reader.ReadElementContentAsString(); break; case "company_name": CompanyName = reader.ReadElementContentAsString(); break; case "vat_number": VatNumber = reader.ReadElementContentAsString(); break; case "tax_exempt": TaxExempt = reader.ReadElementContentAsBoolean(); break; case "entity_use_code": EntityUseCode = reader.ReadElementContentAsString(); break; case "accept_language": AcceptLanguage = reader.ReadElementContentAsString(); break; case "cc_emails": CcEmails = reader.ReadElementContentAsString(); break; case "hosted_login_token": HostedLoginToken = reader.ReadElementContentAsString(); break; case "closed_at": if (DateTime.TryParse(reader.ReadElementContentAsString(), out dt)) { ClosedAt = dt; } break; case "created_at": CreatedAt = reader.ReadElementContentAsDateTime(); break; case "updated_at": UpdatedAt = reader.ReadElementContentAsDateTime(); break; case "address": Address = new Address(reader); break; case "vat_location_valid": if (reader.GetAttribute("nil") == null) { VatLocationValid = reader.ReadElementContentAsBoolean(); } break; case "has_live_subscription": bool a; if (bool.TryParse(reader.ReadElementContentAsString(), out a)) { HasLiveSubscription = a; } break; case "has_active_subscription": bool b; if (bool.TryParse(reader.ReadElementContentAsString(), out b)) { HasActiveSubscription = b; } break; case "has_future_subscription": bool c; if (bool.TryParse(reader.ReadElementContentAsString(), out c)) { HasFutureSubscription = c; } break; case "has_canceled_subscription": bool d; if (bool.TryParse(reader.ReadElementContentAsString(), out d)) { HasCanceledSubscription = d; } break; case "has_past_due_invoice": bool e; if (bool.TryParse(reader.ReadElementContentAsString(), out e)) { HasPastDueInvoice = e; } break; case "preferred_locale": PreferredLocale = reader.ReadElementContentAsString(); break; } } }