/// <summary>
        /// Initializes a new instance of the <see cref="BraintreePaymentMethodApiService"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <param name="customerApiService">
        /// The customer api provider.
        /// </param>
        internal BraintreePaymentMethodApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings, IBraintreeCustomerApiService customerApiService)
            : base(merchelloContext, settings)
        {
            Mandate.ParameterNotNull(customerApiService, "customerApiProvider");

            _braintreeCustomerApiService = customerApiService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BraintreeApiService"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <remarks>
        /// Used for testing
        /// </remarks>
        internal BraintreeApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(settings, "settings");

            this._settings = settings;

            this.Initialize(merchelloContext);
        }
 /// <summary>
 /// Utility extension the deserializes BraintreeProviderSettings from the ExtendedDataCollection
 /// </summary>
 /// <param name="extendedData">
 /// The extended data.
 /// </param>
 /// <returns>
 /// The <see cref="BraintreeProviderSettings"/>.
 /// </returns>
 public static BraintreeProviderSettings GetBrainTreeProviderSettings(this ExtendedDataCollection extendedData)
 {
     BraintreeProviderSettings settings;
     if (extendedData.ContainsKey(Constants.ExtendedDataKeys.BraintreeProviderSettings))
     {
         var json = extendedData.GetValue(Constants.ExtendedDataKeys.BraintreeProviderSettings);
         settings = JsonConvert.DeserializeObject<BraintreeProviderSettings>(json);
     }
     else
     {
         settings = new BraintreeProviderSettings();
     }
     return settings;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BraintreeApiRequestFactory"/> class.
        /// </summary>
        /// <param name="settings">
        /// The settings.
        /// </param>
        public BraintreeApiRequestFactory(BraintreeProviderSettings settings)
        {
            Mandate.ParameterNotNull(settings, "settings");

            _settings = settings;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeWebhooksApiService"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreeWebhooksApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings) 
     : base(merchelloContext, settings)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreePaymentMethodApiService"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreePaymentMethodApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings)
     : this(merchelloContext, settings, new BraintreeCustomerApiService(merchelloContext, settings))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreePaymentMethodApiService"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreePaymentMethodApiService(BraintreeProviderSettings settings)
     : this(Core.MerchelloContext.Current, settings)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeTransactionApiService"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 internal BraintreeTransactionApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings)
     : base(merchelloContext, settings)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeTransactionApiService"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreeTransactionApiService(BraintreeProviderSettings settings)
     : this(Core.MerchelloContext.Current, settings)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeApiService"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreeApiService(BraintreeProviderSettings settings)
     : this(MerchelloContext.Current, settings)
 {
 }
 /// <summary>
 /// Utility extension to quickly serialize <see cref="BraintreeProviderSettings"/> to an extended data value
 /// </summary>
 /// <param name="extendedData">
 /// The extended data.
 /// </param>
 /// <param name="settings">
 /// The <see cref="BraintreeProviderSettings"/>
 /// </param>
 public static void SaveProviderSettings(this ExtendedDataCollection extendedData, BraintreeProviderSettings settings)
 {
     var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
     var json = JsonConvert.SerializeObject(settings, Formatting.None, jsonSerializerSettings);
     extendedData.SetValue(Constants.ExtendedDataKeys.BraintreeProviderSettings, json);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeCustomerApiService"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="settings">
 /// The settings.
 /// </param>
 internal BraintreeCustomerApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings)
     : base(merchelloContext, settings)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeCustomerApiService"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public BraintreeCustomerApiService(BraintreeProviderSettings settings)
     : this(Core.MerchelloContext.Current, settings)
 {
 }
 /// <summary>
 /// Utility extension to quickly serialize <see cref="BraintreeProviderSettings"/> to an extended data value
 /// </summary>
 /// <param name="extendedData">
 /// The extended data.
 /// </param>
 /// <param name="settings">
 /// The <see cref="BraintreeProviderSettings"/>
 /// </param>
 public static void SaveProviderSettings(this ExtendedDataCollection extendedData, BraintreeProviderSettings settings)
 {
     var json = JsonConvert.SerializeObject(settings);
     extendedData.SetValue(Constants.ExtendedDataKeys.BraintreeProviderSettings, json);
 }