Exemplo n.º 1
0
        public ActionResult OnPaymentComplete()
        {
            Guid requestId;
            var  referral = Request.QueryString["ref"];

            if (!Guid.TryParse(Request.QueryString["requestId"], out requestId))
            {
                return(Redirect2PaymentError("RequestId required"));
            }

            if (String.IsNullOrEmpty(Request.QueryString["PayerID"]))
            {
                return(Redirect2PaymentError("PayerID required"));
            }

            string error;
            var    orderNo = -1;

            var baseInfo = _paypalServices.GetItemInfoFromPaymentRequest(requestId);

            if (!baseInfo.IsValid)
            {
                return(Redirect2PaymentError("Request not found"));
            }

            var executed = _paypalServices.ExecutePayPalPayment(requestId, Request.QueryString["PayerID"], out error, Session.SessionID) && _billingServices.CompletePaymentRequest(requestId, out orderNo, out error);


            CheckoutBase.IsValid = executed;
            CheckoutBase.Message = error;

            //return executed ? ReturnPurchaseSuccess(baseInfo.PriceLineId, orderNo, baseInfo.TrackingId, referral) : View("Failure", CheckoutBase);
            return(RedirectToAction("PurchaseResult", new
            {
                isValid = executed,
                actionKind = eActionKinds.POST,
                id = baseInfo.PriceLineId,
                itemName = baseInfo.ItemName,
                trackingId = baseInfo.TrackingId,
                orderNo,
                error,
                referral
            }));
        }
Exemplo n.º 2
0
        public ActionResult OnPaymentComplete(string refferal)
        {
            Guid requestId;

            if (!Guid.TryParse(Request.QueryString["id"], out requestId))
            {
                return(Redirect2PaymentError("RequestId required", string.Empty, -1, string.Empty, eActionKinds.POST, refferal));
            }

            if (String.IsNullOrEmpty(Request.QueryString["PayerID"]))
            {
                return(Redirect2PaymentError("PayerID required", string.Empty, -1, string.Empty, eActionKinds.POST, refferal));
            }

            string error;
            var    orderNo = -1;

            var baseInfo = _paypalServices.GetItemInfoFromPaymentRequest(requestId);

            if (!baseInfo.IsValid)
            {
                return(Redirect2PaymentError("Request not found", string.Empty, -1, string.Empty, eActionKinds.POST, refferal));
            }

            var executed = _paypalServices.ExecutePayPalPayment(requestId, Request.QueryString["PayerID"], out error, Session.SessionID) && _billingServices.CompletePaymentRequest(requestId, out orderNo, out error);

            //return executed ? View("PurchaseResult", new PurchaseResultToken { IsValid = true, ActionKind = eActionKinds.POST, RedirectUrl = Url.Action("PurchaseComplete", "Payment", new { area = "Widget", id = orderNo, trackingId = baseInfo.TrackingId }) }) :
            //                  Redirect2PaymentError(error ?? "unexpected error", baseInfo.ItemName, baseInfo.PriceLineId, baseInfo.TrackingId, eActionKinds.POST);

            return(RedirectToAction("PurchaseResult", new
            {
                isValid = executed,
                actionKind = eActionKinds.POST,
                lineId = baseInfo.PriceLineId,
                itemName = baseInfo.ItemName,
                trackingId = baseInfo.TrackingId,
                orderNo,
                error,
                refferal
            }));
        }