/// <summary>
        /// Creates a checkout preference. 
        /// </summary>
        public Preference CreatePreference(Preference preference)
        {
            JSONObject json = _api.Post(SettingsHelper.PreferencesUri, preference.ToJSON(), ContentType.JSON);
            preference = new Preference(json);

            return preference;
        }
        /// <summary>
        /// Creates a checkout preference. 
        /// </summary>
        public Preference CreatePreference(Preference preference)
        {
            JSONObject json = _api.Post(Properties.Settings.Default.PreferencesUri, preference.ToJSON(), ContentType.JSON);
            preference = new Preference(json);

            return preference;
        }
        // Create a checkout preference
        private Preference CreatePreference(Int16 amount, string email)
        {
            // Set Checkout Helper
            CheckoutHelper ch = new CheckoutHelper();

            // Create token
            Token token = ch.CreateAccessToken(Properties.Settings.Default.ClientId, Properties.Settings.Default.ClientSecret);
            ch.AccessToken = token.AccessToken;

            // Set item
            Item item = new Item();
            item.CurrencyId = Properties.Settings.Default.CurrencyId;
            item.Description = Properties.Settings.Default.Description;
            item.Id = Properties.Settings.Default.ItemId;
            item.PictureUrl = Properties.Settings.Default.ImageUrl;
            item.Quantity = 1;
            item.Title = Properties.Settings.Default.Title;
            item.UnitPrice = amount;

            // Set preference
            Preference preference = new Preference();
            preference.BackUrls = new ResponseUrls();
            preference.BackUrls.Failure = Properties.Settings.Default.FailureUrl;
            preference.BackUrls.Pending = Properties.Settings.Default.PendingUrl;
            preference.BackUrls.Success = Properties.Settings.Default.SuccessUrl;
            preference.ExternalReference = "my id";  // your id for this transaction
            preference.Items = new ItemList();
            preference.Items.Add(item);
            preference.Payer = new UserEx();
            preference.Payer.Email = email;
            preference.CustomPaymentChoices = new PaymentChoices();
            preference.CustomPaymentChoices.ExcludedTypes = new IdList();  // remove ticket and bank transfer options
            preference.CustomPaymentChoices.ExcludedTypes.Add("ticket");
            preference.CustomPaymentChoices.ExcludedTypes.Add("bank_transfer");

            // Create preference
            preference = ch.CreatePreference(preference);

            return preference;
        }
 /// <summary>
 /// Updates a checkout preference. 
 /// </summary>		
 public Preference UpdatePreference(Preference preference)
 {
     return null;
 }
 /// <summary>
 /// Updates a checkout preference.
 /// </summary>
 public Preference UpdatePreference(Preference preference)
 {
     return(null);
 }