Beispiel #1
0
        public EntityList <PaymentSource> ListPaymentSources()
        {
            PaymentSource source = new PaymentSource(this.GetConnection());

            source.SetEndpointBase(this.GetEndpoint(true));
            return(source.ListAll(null, null, new PaymentSourceConverter()));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }