コード例 #1
0
ファイル: OrderApi.cs プロジェクト: Kooboo/Ecommerce
        public PaymentResult Pay(PaymentRequest request)
        {
            var paymentMethod = _context.Database.Repository<Core.PaymentMethod>().Find(request.PaymentMethodId);
            var payment = new Kooboo.Commerce.Payments.Payment(request.OrderId, request.Amount, paymentMethod, request.Description);

            var paymentService = new Core.PaymentService(_context.Instance);

            paymentService.Create(payment);

            // TODO: Consider move ProcessPayment to PaymentService
            var processor = _paymentProcessorProvider.FindByName(paymentMethod.ProcessorName);
            object config = null;

            if (processor.ConfigType != null)
            {
                config = paymentMethod.LoadProcessorConfig(processor.ConfigType);
            }

            var processResult = processor.Process(new Kooboo.Commerce.Payments.PaymentProcessingContext(payment, config)
            {
                CurrencyCode = request.CurrencyCode,
                ReturnUrl = request.ReturnUrl,
                Parameters = request.Parameters
            });

            paymentService.AcceptProcessResult(payment, processResult);

            return new PaymentResult
            {
                Message = processResult.Message,
                PaymentId = payment.Id,
                PaymentStatus = (Kooboo.Commerce.Api.Payments.PaymentStatus)(int)processResult.PaymentStatus,
                RedirectUrl = processResult.RedirectUrl
            };
        }
コード例 #2
0
ファイル: OrderApi.cs プロジェクト: Smilefounder/Ecommerce
        public PaymentResult Pay(PaymentRequest request)
        {
            var paymentMethod = _context.Database.Repository <Core.PaymentMethod>().Find(request.PaymentMethodId);
            var payment       = new Kooboo.Commerce.Payments.Payment(request.OrderId, request.Amount, paymentMethod, request.Description);

            var paymentService = new Core.PaymentService(_context.Instance);

            paymentService.Create(payment);

            // TODO: Consider move ProcessPayment to PaymentService
            var    processor = _paymentProcessorProvider.FindByName(paymentMethod.ProcessorName);
            object config    = null;

            if (processor.ConfigType != null)
            {
                config = paymentMethod.LoadProcessorConfig(processor.ConfigType);
            }

            var processResult = processor.Process(new Kooboo.Commerce.Payments.PaymentProcessingContext(payment, config)
            {
                CurrencyCode = request.CurrencyCode,
                ReturnUrl    = request.ReturnUrl,
                Parameters   = request.Parameters
            });

            paymentService.AcceptProcessResult(payment, processResult);

            return(new PaymentResult
            {
                Message = processResult.Message,
                PaymentId = payment.Id,
                PaymentStatus = (Kooboo.Commerce.Api.Payments.PaymentStatus)(int) processResult.PaymentStatus,
                RedirectUrl = processResult.RedirectUrl
            });
        }
コード例 #3
0
ファイル: iDealController.cs プロジェクト: Kooboo/Ecommerce
 public iDealController(
     SettingService keyValueService,
     PaymentService paymentService,
     PaymentMethodService paymentMethodService)
 {
     _keyValueService = keyValueService;
     _paymentService = paymentService;
     _paymentMethodService = paymentMethodService;
 }
コード例 #4
0
 public BuckarooController(PaymentService paymentService, PaymentMethodService paymentMethodService)
 {
     _paymentService = paymentService;
     _paymentMethodService = paymentMethodService;
 }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: Kooboo/Ecommerce
 public HomeController(PaymentService paymentService, PaymentMethodService paymentMethodService)
 {
     _paymentService = paymentService;
     _paymentMethodService = paymentMethodService;
 }