Esempio n. 1
0
        public ActionResult OnSubscriptionComplete(Guid?requestId)
        {
            var    referral = Request.QueryString["ref"];
            string error;
            var    reqId = requestId;

            if (reqId == null)
            {
                return(Redirect2PaymentError("requestId missing"));
            }

            var baseInfo = _paypalServices.GetItemInfoFromPaymentRequest((Guid)reqId);

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

            if (String.IsNullOrEmpty(Request.QueryString["TOKEN"]))
            {
                _paypalServices.UpdatePaypalRequestStatus((Guid)reqId, BillingEnums.ePaymentRequestStatus.failed, out error);

                return(Redirect2PaymentError("token missing"));
            }

            var agreement_token = Request.QueryString["TOKEN"];

            CreditCardDTO card = null;

            if (Session["RecurringCc"] != null)
            {
                card = Session["RecurringCc"] as CreditCardDTO;
            }

            RecurringPaymentExecutionResultToken result;

            var orderNo = -1;

            var executed = _paypalServices.ExecuteCourseSubscriptionPayalRecurringPayment(CurrentUserId, (Guid)reqId, agreement_token, card, out result, out error, Session.SessionID) && _billingServices.CompleteSubscriptionRequest(result, out orderNo, out error);

            //if (executed) return ReturnPurchaseSuccess(baseInfo.PriceLineId, orderNo, baseInfo.TrackingId, referral);

            //CheckoutBase.Message = error;

            //return View("Failure", CheckoutBase);

            return(RedirectToAction("PurchaseResult", new
            {
                isValid = executed,
                actionKind = eActionKinds.POST,
                id = baseInfo.PriceLineId,
                itemName = baseInfo.ItemName,
                trackingId = baseInfo.TrackingId,
                orderNo,
                error,
                referral
            }));
        }
Esempio n. 2
0
        public ActionResult OnSubscriptionComplete(Guid?id, string refferal)
        {
            string error;
            var    requestId = id;

            if (requestId == null)
            {
                return(Redirect2PaymentError("requestId missing", string.Empty, -1, string.Empty, eActionKinds.POST, refferal));
            }

            var baseInfo = _paypalServices.GetItemInfoFromPaymentRequest((Guid)requestId);

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

            if (String.IsNullOrEmpty(Request.QueryString["TOKEN"]))
            {
                _paypalServices.UpdatePaypalRequestStatus((Guid)requestId, BillingEnums.ePaymentRequestStatus.failed, out error);

                return(Redirect2PaymentError("token missing", baseInfo.ItemName, baseInfo.PriceLineId, baseInfo.TrackingId, eActionKinds.POST, refferal));
            }

            var agreement_token = Request.QueryString["TOKEN"];

            CreditCardDTO card = null;

            if (Session["RecurringCc"] != null)
            {
                card = Session["RecurringCc"] as CreditCardDTO;
            }

            RecurringPaymentExecutionResultToken result;

            var orderNo = -1;

            var executed = _paypalServices.ExecuteCourseSubscriptionPayalRecurringPayment(CurrentUserId, (Guid)requestId, agreement_token, card, out result, out error, Session.SessionID) && _billingServices.CompleteSubscriptionRequest(result, 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
            }));
        }