public EntityList <PaymentSource> ListPaymentSources() { PaymentSource source = new PaymentSource(this.GetConnection()); source.SetEndpointBase(this.GetEndpoint(true)); return(source.ListAll(null, null, new PaymentSourceConverter())); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); string objType = (string)jo["object"]; PaymentSource item; if (objType == "bank_account") { item = new BankAccount(); } else if (objType == "card") { item = new Card(); } else { item = new PaymentSource(); } serializer.Populate(jo.CreateReader(), item); return(item); }
public PaymentSource CreatePaymentSource(SourceRequest sourceRequest) { string url = this.GetEndpoint(true) + "/payment_sources"; PaymentSource output = null; try { string sourceRequestJson = sourceRequest.ToJsonString(); string response = this.GetConnection().Post(url, null, sourceRequestJson); JsonSerializerSettings sourceSettings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore }; sourceSettings.Converters.Add(new PaymentSourceConverter()); output = JsonConvert.DeserializeObject <PaymentSource>(response, sourceSettings); output.ChangeConnection(this.GetConnection()); output.SetEndpointBase(this.GetEndpoint(true)); } catch (Exception e) { throw new EntityException("", e); } return(output); }