コード例 #1
0
ファイル: Customer.cs プロジェクト: somadrid/conekta-.net
        /// <summary>
        /// Creates the offline recurrent reference.
        /// </summary>
        /// <returns>The OfflineRecurrentReference.</returns>
        /// <param name="data">Reference data.</param>
        public PaymentSource CreateOfflineRecurrentReference(string data)
        {
            string reference = this.create("/customers/" + this.id + "/payment_sources", data);
            OfflineRecurrentReference skeleton = new OfflineRecurrentReference();
            JObject cardObject = skeleton.toObject(reference);

            return((PaymentSource)skeleton.ToClass(cardObject.ToString()));
        }
コード例 #2
0
        public OfflineRecurrentReference ToClass(string json)
        {
            OfflineRecurrentReference reference = JsonConvert.DeserializeObject <OfflineRecurrentReference>(json, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(reference);
        }
コード例 #3
0
ファイル: Customer.cs プロジェクト: somadrid/conekta-.net
        public Customer toClass(string json)
        {
            JObject data = JObject.Parse(json);
            JArray  paymentSourcesData = (JArray)data.GetValue("payment_sources");

            data.Remove("payment_sources");

            Customer customer = JsonConvert.DeserializeObject <Customer>(json, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            if (paymentSourcesData != null && paymentSourcesData.Count > 0)
            {
                for (int x = 0; x < paymentSourcesData.Count; x++)
                {
                    JObject item = (JObject)paymentSourcesData[x];

                    if (item.GetValue("type").ToString() == "oxxo_recurrent")
                    {
                        OfflineRecurrentReference paymentSource = JsonConvert.DeserializeObject <OfflineRecurrentReference>(item.ToString(), new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        customer.payment_sources[x] = paymentSource;
                    }
                    else
                    {
                        Card paymentSource = JsonConvert.DeserializeObject <Card>(item.ToString(), new JsonSerializerSettings
                        {
                            NullValueHandling = NullValueHandling.Ignore
                        });

                        customer.payment_sources[x] = paymentSource;
                    }
                }
            }

            return(customer);
        }
コード例 #4
0
        public OfflineRecurrentReference Update(string data)
        {
            OfflineRecurrentReference payment_source = this.ToClass(this.toObject(this.update("/customers/" + this.parent_id + "/payment_sources/" + this.id, data)).ToString());

            return(payment_source);
        }