public IActionResult Get([FromServices] PaypalConfiguration configuration)
 {
     return(Ok(ApiModel.AsSuccess(new PaypalConfigurationBindings
     {
         sandbox = configuration.ClientIdSandbox,
         production = configuration.ClientIdProduction,
         Environment = configuration.Environment
     })));
 }
        public static OurOrdersBuilder UsePayPal(this OurOrdersBuilder builder, string clientIdSandbox, string clientIdProduction, string secretSandbox, string secretProduction, string environment)
        {
            var paypalConfiguration = new PaypalConfiguration()
            {
                Environment        = environment,
                ClientIdSandbox    = clientIdSandbox,
                ClientIdProduction = clientIdProduction,
                SecretSandbox      = secretSandbox,
                SecretProduction   = secretProduction,
            };

            return(builder.UsePayPal(paypalConfiguration));
        }
        public static OurOrdersBuilder UsePayPal(this OurOrdersBuilder builder, PaypalConfiguration paypalConfiguration)
        {
            builder.AppEvents.Configure += (sender, services) =>
            {
                services.AddTransient <IPaymentProvider, PayPalPaymentProvider>();
                services.AddTransient <PayPalPaymentProvider>();
                services.AddSingleton(paypalConfiguration);
            };

            builder.AppSettings.ExternalControllers.Add(typeof(PayPalPaymentController));

            builder.HostServices.AddSingleton(paypalConfiguration);
            builder.HostServices.AddTransient <IPaymentProvider, PayPalPaymentProvider>();
            builder.HostServices.AddTransient <PayPalPaymentProvider>();

            return(builder);
        }
Example #4
0
 public PayPalPaymentProvider(OrderService orderService, PaypalConfiguration configuration)
 {
     this.orderService  = orderService;
     this.configuration = configuration;
 }