Ejemplo n.º 1
0
        //
        // GET: /Payment/

        public void Index()
        {
            var checkout = TempData["checkoutInfo"] as Checkout;
            var cart     = Session["Cart"] as List <CartItem>;
            var paypal   = new PayPalManagement
            {
                Checkout          = checkout,
                WebResponse       = Response,
                CancelUrl         = Url.Action("PaymentCancellation", null, null, Request.Url.Scheme),
                CheckoutReturnUrl = Url.Action("PaymentReceived", null, null, Request.Url.Scheme),
                Cart = cart
            };

            TempData["checkoutInfo"] = checkout;
            paypal.SetQuickCheckOut();
        }
Ejemplo n.º 2
0
    private void cmdChangePlan_Click(object sender, EventArgs e)
    {
        Subscription        currentSubscription;
        SubscriptionActions actionInfo;
        Plan           selectedPlan;
        bool           payMonthly;
        PayPalInterval interval;
        string         redirectUrl = "";

        currentSubscription = getCurrentSubscription();
        selectedPlan        = getSelectedPlan(lstPlans.SelectedValue, out payMonthly);
        interval            = new PayPalInterval(1, payMonthly ? IntervalUnits.Months : IntervalUnits.Years);

        actionInfo = PayPalManagement.GetSubscriptionAction(currentSubscription, selectedPlan, interval, _userId);

        if (actionInfo.Action == ActionTypes.NoChange)
        {
            return;
        }
        else if (actionInfo.Action == ActionTypes.Cancel)
        {
            //Todo: build a cancellation URL
            throw new NotImplementedException();
        }
        else if (actionInfo.Action == ActionTypes.StartPlan)
        {
            redirectUrl = PayPalUrl.BuildPayPalUrl(selectedPlan, actionInfo.NewSubscription.Id, false, payMonthly, getReturnUrl());
        }
        else if (actionInfo.Action == ActionTypes.Modify)
        {
            redirectUrl = PayPalUrl.BuildPayPalUrl(selectedPlan, actionInfo.NewSubscription.Id, true, payMonthly, getReturnUrl());
        }

        if (actionInfo.NewSubscription != null)
        {
            _db.ORManager.Save(actionInfo.NewSubscription);
        }

        if (redirectUrl.Length > 0)
        {
            Response.Redirect(redirectUrl);
        }
    }
Ejemplo n.º 3
0
        public ActionResult PaymentReceived(string token, string payerId)
        {
            var checkout         = TempData["checkoutInfo"] as Checkout;
            var cart             = Session["Cart"] as List <CartItem>;
            var payPalManagement = new PayPalManagement
            {
                Checkout          = checkout,
                WebResponse       = Response,
                CancelUrl         = Url.Action("PaymentCancellation"),
                CheckoutReturnUrl = Url.Action("PaymentReceived"),
                Cart = cart
            };

            TempData["checkoutInfo"] = checkout;
            var response = payPalManagement.DoExpressCheckout(Response, token);

            if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0))
            {
                return(PaymentFailed(response.Errors.Select(x => x.LongMessage)));
            }

            return(PaymentResponseSuccess(response, checkout, cart));
        }