/// <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> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> saveEventArgs) { var key = new Guid("D143E0F6-98BB-4E0A-8B8C-CE9AD91B0969"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } var settings = new BraintreeProviderSettings() { PrivateKey = string.Empty, PublicKey = string.Empty, DefaultTransactionOption = TransactionOption.SubmitForSettlement, MerchantDescriptor = new MerchantDescriptor() { Name = string.Empty, Phone = string.Empty, Url = string.Empty }, MerchantId = string.Empty, Environment = EnvironmentType.Sandbox }; provider.ExtendedData.SaveProviderSettings(settings); }
/// <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> /// Initializes a new instance of the <see cref="BraintreeApiServiceBase"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="settings"> /// The settings. /// </param> protected BraintreeApiServiceBase(IMerchelloContext merchelloContext, BraintreeProviderSettings settings) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); Mandate.ParameterNotNull(settings, "settings"); this.MerchelloContext = merchelloContext; this.BraintreeGateway = settings.AsBraintreeGateway(); this.Initialize(settings); }
/// <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> /// 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); }
public void Can_Map_BrainTreeProviderSettings_To_BrainTreeGateway() { //// Arrange //// Act var gateway = BraintreeProviderSettings.AsBraintreeGateway(); //// Assert Assert.NotNull(gateway); Assert.AreEqual(BraintreeProviderSettings.Environment, gateway.Environment); Assert.AreEqual(BraintreeProviderSettings.PublicKey, gateway.PublicKey); Assert.AreEqual(BraintreeProviderSettings.PrivateKey, gateway.PrivateKey); Assert.AreEqual(BraintreeProviderSettings.MerchantId, gateway.MerchantId); Assert.AreEqual(TransactionOption.SubmitForSettlement, BraintreeProviderSettings.DefaultTransactionOption); }
/// <summary> /// Initializes a new instance of the <see cref="RequestBuilderBase{T}"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <exception cref="ArgumentNullException"> /// Throws an exception if the the settings are null /// </exception> protected RequestBuilderBase(IMerchelloContext merchelloContext, BraintreeProviderSettings settings) { if (merchelloContext == null) { throw new ArgumentNullException("merchelloContext"); } if (settings == null) { throw new ArgumentNullException("settings"); } this.MerchelloContext = merchelloContext; this.BraintreeGateway = settings.AsBraintreeGateway(); this.BraintreeRequest = new T(); }
public virtual void TestFixtureSetup() { this.TestCustomer = MerchelloContext.Current.Services.CustomerService.CreateCustomerWithKey( Guid.NewGuid().ToString(), "first", "last", "*****@*****.**"); this.BraintreeProviderSettings = TestHelper.GetBraintreeProviderSettings(); AutoMapperMappings.CreateMappings(); this.Gateway = this.BraintreeProviderSettings.AsBraintreeGateway(); this.BraintreeApiService = new BraintreeApiService(this.BraintreeProviderSettings); }
public void Can_Create_A_Transaction_Request() { //// Arrange var gateway = BraintreeProviderSettings.AsBraintreeGateway(); var request = new TransactionRequest() { Amount = 100M, PaymentMethodNonce = TestHelper.PaymentMethodNonce }; //// Act var result = gateway.Transaction.Sale(request); //// Assert Assert.IsTrue(result.IsSuccess()); }
public void Can_Create_A_Customer() { //// Arrange var gateway = BraintreeProviderSettings.AsBraintreeGateway(); var customerRequest = new CustomerRequest() { CustomerId = CustomerKey.ToString(), FirstName = "Rusty", LastName = "Swayne", Company = "Mindfly", Email = "*****@*****.**", Website = "http://www.mindfly.com" }; //// Act var result = gateway.Customer.Create(customerRequest); //// Assert Assert.IsTrue(result.IsSuccess()); }
/// <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="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="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="BraintreeApiRequestFactory"/> class. /// </summary> /// <param name="settings"> /// The settings. /// </param> public BraintreeApiRequestFactory(BraintreeProviderSettings settings) { Mandate.ParameterNotNull(settings, "settings"); this._settings = 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); }
/// <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> /// Initializes a new instance of the <see cref="BraintreeSubscriptionApiService"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="settings"> /// The settings. /// </param> internal BraintreeSubscriptionApiService(IMerchelloContext merchelloContext, BraintreeProviderSettings settings) : base(merchelloContext, settings) { }
/// <summary> /// Initializes a new instance of the <see cref="BraintreeSubscriptionApiService"/> class. /// </summary> /// <param name="settings"> /// The settings. /// </param> public BraintreeSubscriptionApiService(BraintreeProviderSettings settings) : this(Core.MerchelloContext.Current, settings) { }
/// <summary> /// Maps a <see cref="BraintreeProviderSettings"/> as a <see cref="BraintreeGateway"/> /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="BraintreeGateway"/>. /// </returns> public static BraintreeGateway AsBraintreeGateway(this BraintreeProviderSettings settings) { return(new BraintreeGateway(settings.EnvironmentType.AsEnvironment(), settings.MerchantId, settings.PublicKey, settings.PrivateKey)); }
/// <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> /// Maps a <see cref="BraintreeProviderSettings"/> as a <see cref="BraintreeGateway"/> /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="BraintreeGateway"/>. /// </returns> public static BraintreeGateway AsBraintreeGateway(this BraintreeProviderSettings settings) { return(Mapper.Map <BraintreeGateway>(settings)); }
/// <summary> /// Performs class initialization logic. /// </summary> /// <param name="settings"> /// The settings. /// </param> private void Initialize(BraintreeProviderSettings settings) { this._requestFactory = new Lazy <BraintreeApiRequestFactory>(() => new BraintreeApiRequestFactory(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="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="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="InvoiceTransactionRequestBuilder"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="settings"> /// The settings. /// </param> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce">The "nonce" from the client</param> /// <exception cref="ArgumentNullException"> /// Throws an exception if the invoice is null /// </exception> protected InvoiceTransactionRequestBuilder(IMerchelloContext merchelloContext, BraintreeProviderSettings settings, IInvoice invoice, string paymentMethodNonce) : base(merchelloContext, settings) { if (invoice == null) { throw new ArgumentNullException("invoice"); } if (string.IsNullOrEmpty(paymentMethodNonce)) { throw new ArgumentNullException("paymentMethodNonce"); } this._invoice = invoice; this._paymentMethodNonce = paymentMethodNonce; this.Initialize(); }