コード例 #1
0
 public void RequestPayment(PaymentRequest e)
 {
     e.ActionResult = new RedirectToRouteResult(new RouteValueDictionary {
         {"action", "Index"},
         {"controller", "PaypalResponse"},
         {"area", "Cascade.Paypal"},
         {"orderReference", e.Order.Number},
         {"amount", (int)(e.Order.Total * 100)}
     });
     e.WillHandlePayment = true;
 }
コード例 #2
0
        public void RequestPayment(PaymentRequest e)
        {

            e.ActionResult = new RedirectToRouteResult(new RouteValueDictionary {
                {"action", "Index"},
                {"controller", "SimulatedPaymentServiceProvider"},
                {"area", "Cascade.WebShop"},
                {"orderReference", e.Order.Number},
                {"amount", (int)(e.Order.Total * 100)}
            });

            e.WillHandlePayment = true;
        }
コード例 #3
0
        public ActionResult Create()
        {
            var user = _authenticationService.GetAuthenticatedUser();

            if (user == null)
                throw new OrchardSecurityException(_t("Login required"));

            var customer = user.ContentItem.As<CustomerPart>();

            if (customer == null)
                throw new InvalidOperationException("The current user is not a customer");

            var order = _orderService.CreateOrder(customer.Id, _shoppingCart.Items);

            // wire up the shipping address that we left dangling
            var shippingAddress = _customerService.GetShippingAddress(user.Id, 0);
            if (shippingAddress != null)
            {
                shippingAddress.OrderId = order.Id;
                _contentManager.Publish(shippingAddress.ContentItem);
            }

            // Todo: Give paymet service providers a chance to process payment by sending a event. 
            // If no PSP handled the event, we'll just continue by displaying the created order.
            // Raise an OrderCreated event
            // Fire the PaymentRequest event
            var paymentRequest = new PaymentRequest(order);

            foreach (var handler in _paymentServiceProviders)
            {
                handler.RequestPayment(paymentRequest);

                // If the handler responded, it will set the action result
                if (paymentRequest.WillHandlePayment)
                {
                    return paymentRequest.ActionResult;
                }
            }

            // If we got here, no PSP handled the OrderCreated event, so we'll just display the order.
            var shape = _shapeFactory.Order_Created(
                Order: order,
                Products: _orderService.GetProducts(order.Details).ToArray(),
                Customer: customer,
                InvoiceAddress: (dynamic)_customerService.GetInvoiceAddress(user.Id),
                ShippingAddress: (dynamic)shippingAddress
            );
            return new ShapeResult(this, shape);
        }