示例#1
0
    private void ProcessPayPalStandardIPN()
    {
        OrderNotifyService order = new OrderNotifyService(Invoice);
        Order details            = DataAccessContext.OrderRepository.GetOne(order.OrderID);

        if (String.IsNullOrEmpty(details.GatewayPaymentStatus))
        {
            order.SendOrderEmail();
        }

        details.GatewayOrderID       = Invoice;
        details.GatewayPaymentStatus = PaymentStatus;
        DataAccessContext.OrderRepository.Save(details);

        // Create the IPN Transaction
        switch (PaymentStatus.ToLower())
        {
        case "completed":
        case "canceled_reversal":
            order.ProcessPaymentComplete();
            break;

        case "refunded":
        case "reversed":
            order.ProcessPaymentFailed();
            break;
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string result = Request.Form["result"];
        string orderID;

        orderID = result.Substring(2, result.Length - 2);
        string amount = Request.Form["amt"];
        string apCode = Request.Form["apCode"];

        string resultCode = result.Substring(0, 2);

        if (resultCode == "00") //success
        {
            OrderNotifyService order = new OrderNotifyService(orderID);
            order.SendOrderEmail();
            order.ProcessPaymentComplete();

            //Response.Write( resultCode + "<br>" + orderID );
        }
        else
        {
            Order order = DataAccessContext.OrderRepository.GetOne(orderID);
            order.GatewayOrderID       = apCode;
            order.GatewayPaymentStatus = "testja";
            DataAccessContext.OrderRepository.Save(order);

            //01 not enough fund
            //99 Unknow Error
            //Show error
        }
    }
示例#3
0
    private OrderNotifyService CreateOrder(CheckoutDetails checkout)
    {
        OrderCreateService orderCreateService = new OrderCreateService(
            StoreContext.ShoppingCart,
            checkout,
            StoreContext.Culture,
            StoreContext.Currency,
            AffiliateHelper.GetAffiliateCode(),
            WebUtilities.GetVisitorIP());

        OrderNotifyService orderBusiness;
        Order       order;
        OrderAmount orderAmount;

        if (!IsAnonymousCheckout())
        {
            order         = PlaceOrder(orderCreateService, out orderAmount);
            orderBusiness = new OrderNotifyService(order.OrderID);
        }
        else
        {
            order = PlaceOrderAnonymous(
                SystemConst.AnonymousUser, orderCreateService, checkout, out orderAmount);

            orderBusiness = new OrderNotifyService(order.OrderID);
        }

        AffiliateOrder affiliateorder = new AffiliateOrder();

        affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
        affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

        return(orderBusiness);
    }
    private void SaveDataKPayment()
    {
        string result = "IsApproved:" + IsApproved.ToString() + ", ";

        result += String.Format("RespCode:{0}, ", RespCode);
        result += String.Format("AuthCode:{0}, ", AuthCode);
        result += String.Format("UAID:{0}, ", UAID);
        result += String.Format("CardType:{0}", CardType);

        PaymentLog paymentLog = new PaymentLog();

        paymentLog.OrderID         = BankInvoiceID;
        paymentLog.PaymentResponse = result;
        paymentLog.PaymentGateway  = GetPaymentName();
        paymentLog.PaymentType     = String.Empty;
        DataAccessContext.PaymentLogRepository.Save(paymentLog);
        //PaymentLogAccess.Create( BankInvoiceID, result, GetPaymentName(), "" );

        OrderNotifyService order = new OrderNotifyService(BankInvoiceID);

        if (IsApproved)
        {
            order.SendOrderEmail();
            order.ProcessPaymentComplete();

            Response.Redirect(String.Format("~/CheckoutComplete.aspx?OrderID={0}&IsTransaction=True", BankInvoiceID));
        }
        else
        {
            order.ProcessPaymentFailed();

            Response.Redirect(String.Format("~/CheckoutNotComplete.aspx?OrderID={0}", BankInvoiceID));
        }
    }
    private void ProcessOnWebsiteRequireOrderIDPayment(CheckoutDetails checkout)
    {
        OnWebsiteRequireOrderIDPaymentMethod payment = (OnWebsiteRequireOrderIDPaymentMethod)checkout.PaymentMethod;

        OrderNotifyService order = CreateOrder(checkout);

        PaymentAppGateway gateway  = new PaymentAppGateway(checkout);
        string            postData = gateway.CreateOnWebsitePaymentXml(
            StoreContext.Culture,
            StoreContext.GetOrderAmount().Total,
            order.OrderID,
            WebUtilities.GetVisitorIP(),
            UrlPath.StorefrontUrl,
            true);

        PaymentAppResult paymentResult = gateway.PostCommand(new HttpService(), postData, UrlPath.StorefrontUrl);

        if (paymentResult.Status == PaymentAppResult.PaymentStatus.OK)
        {
            ProcessCreditCardPaymentSuccess(
                order,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
    private OrderNotifyService CreateOrder(CheckoutDetails checkout)
    {
        OrderCreateService orderCreateService = new OrderCreateService(
            StoreContext.ShoppingCart,
            checkout,
            StoreContext.Culture,
            CurrenntCurrency,
            AffiliateHelper.GetAffiliateCode(),
            WebUtilities.GetVisitorIP());

        OrderNotifyService orderBusiness;
        OrderAmount        amount = orderCreateService.GetOrderAmount(StoreContext.Customer)
                                    .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                             checkout,
                                             StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                             StoreContext.Customer));

        Order order = orderCreateService.PlaceOrder(amount,
                                                    StoreContext.Customer, DataAccessContext.StoreRetriever, StoreContext.Culture);

        GiftRegistry.UpdateGiftRegistryQuantity(StoreContext.ShoppingCart, checkout);
        CustomerRewardPoint.UpdateRedeemPoint(checkout, StoreContext.Customer, order);

        orderBusiness = new OrderNotifyService(order.OrderID);

        return(orderBusiness);
    }
    //private string GetPaymentName()
    //{
    //    //PaymentMethod payment;
    //    //payment = new TwoCheckoutPaymentMethod();

    //    //return payment.Name;
    //    return "2Checkout";
    //}

    protected void Page_Load(object sender, EventArgs e)
    {
        string storeUrl = DataAccessContext.StoreRetriever.GetStorefrontUrlByOrderID(OrderID);

        if (VerifyReferrer())
        {
            PaymentLog paymentLog = new PaymentLog();
            paymentLog.OrderID         = OrderID;
            paymentLog.PaymentResponse = Request.Form.ToString();
            paymentLog.PaymentGateway  = "2Checkout";
            paymentLog.PaymentType     = String.Empty;
            DataAccessContext.PaymentLogRepository.Save(paymentLog);
            //PaymentLogAccess.Create( OrderID, Request.Form.ToString(), GetPaymentName(), "" );

            if (CreditCardProcess == "Y")
            {
                UpdateOrderDetails();

                OrderNotifyService order = new OrderNotifyService(OrderID);
                order.SendOrderEmail();
                order.ProcessPaymentComplete();

                Response.Redirect(String.Format("{0}/CheckoutComplete.aspx?OrderID={1}", storeUrl, OrderID + "&IsTransaction=true"));
            }
            else
            {
                Response.Redirect(String.Format("{0}/CheckoutNotComplete.aspx?OrderID={1}", storeUrl, OrderID));
            }
        }
        else
        {
            Response.Redirect(String.Format("{0}/CheckoutNotComplete.aspx?OrderID={1}", storeUrl, OrderID));
        }
    }
示例#8
0
    private void ProcessRBSWorldPayIPN()
    {
        OrderNotifyService order = new OrderNotifyService(Invoice);

        Order orderDetails = DataAccessContext.OrderRepository.GetOne(order.OrderID);

        if (PaymentStatus.ToUpper() == "Y")
        {
            order.SendOrderEmail();
        }

        //OrdersAccess.UpdateGatewayOrderID( Invoice, TransID );
        //OrdersAccess.UpdateGatewayStatusByGatewayOrderID( TransID, PaymentStatus );

        orderDetails.GatewayOrderID       = TransID;
        orderDetails.GatewayPaymentStatus = PaymentStatus;
        VerifyAvsAndCvv(orderDetails);
        string retURL = UrlPath.StorefrontUrl;

        // Create the IPN Transaction
        if (PaymentStatus.ToUpper() == "Y")
        {
            uxCheckoutHeaderLabel.Text = "Thank you for your order.";
            uxCheckoutDetailLabel.Text = "To view order information, please click the link below.";
            order.ProcessPaymentComplete();
            uxCheckoutLink.NavigateUrl
                = String.Format(UrlPath.StorefrontUrl + "CheckoutComplete.aspx?OrderID={0}",
                                order.OrderID + "&IsTransaction=true");
            uxUrlHidden.Value
                = String.Format(UrlPath.StorefrontUrl + "CheckoutComplete.aspx?OrderID={0}",
                                order.OrderID + "&IsTransaction=true");
            uxHomeLink.Visible = false;

            retURL = String.Format(UrlPath.StorefrontUrl + "CheckoutComplete.aspx?OrderID={0}",
                                   order.OrderID + "&IsTransaction=true");
        }
        else
        {
            uxCheckoutHeaderLabel.Text = "Order Not Complete";
            uxCheckoutDetailLabel.Text = "Your Order cannot be completed.<br/><br/>Please verify your payment information and try checkout again.";
            order.ProcessPaymentFailed();
            uxCheckoutLink.NavigateUrl
                = String.Format(UrlPath.StorefrontUrl + "CheckoutNotComplete.aspx?OrderID={0}", order.OrderID);
            uxUrlHidden.Value
                = String.Format(UrlPath.StorefrontUrl + "CheckoutNotComplete.aspx?OrderID={0}", order.OrderID);
            uxCheckoutLink.Visible = false;
            uxHomeLink.NavigateUrl = UrlPath.StorefrontUrl;

            retURL = String.Format(UrlPath.StorefrontUrl + "CheckoutNotComplete.aspx?OrderID={0}", order.OrderID);
        }

        HtmlMeta meta = new HtmlMeta();

        meta.ID        = "meta" + "refresh";
        meta.HttpEquiv = "refresh";
        meta.Content   = "0;URL=" + retURL;
        Page.Header.Controls.Add(meta);
    }
    private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout)
    {
        PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod;
        bool                   result          = false;
        PaymentAppResult       paymentResult;
        RecurringPaymentResult recurringPaymentResult;
        ProcessPaymentService  process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart);

        result = process.ProcessPayPalProUSPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")),
            StoreContext.Culture,
            checkout,
            StoreContext.ShoppingCart,
            StoreContext.Customer,
            UrlPath.StorefrontUrl,
            WebUtilities.GetVisitorIP(),
            out paymentResult,
            out recurringPaymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                StoreContext.CheckoutDetails,
                StoreContext.Culture,
                CurrenntCurrency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP(),
                recurringPaymentResult
                );

            Order       order;
            OrderAmount amount = orderCreateService.GetOrderAmount(StoreContext.Customer)
                                 .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                          StoreContext.CheckoutDetails,
                                          StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                          StoreContext.Customer));
            order = orderCreateService.PlaceOrder(amount, StoreContext.Customer, DataAccessContext.StoreRetriever, StoreContext.Culture);
            GiftRegistry.UpdateGiftRegistryQuantity(StoreContext.ShoppingCart, StoreContext.CheckoutDetails);
            CustomerRewardPoint.UpdateRedeemPoint(StoreContext.CheckoutDetails, StoreContext.Customer, order);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);

            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
示例#10
0
    private void ProcessZeroPricePayment(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        Exception emailEx = order.SendOrderEmailNoThrow();

        StoreError.Instance.Exception = emailEx;

        order.ProcessPaymentComplete();

        StoreContext.ClearCheckoutSession();

        MainContext.RedirectMainControl("OrdersEdit.ascx", String.Format("OrderID={0}", order.OrderID));
    }
示例#11
0
    private void ProcessAnonymousPayment(CheckoutDetails checkout)
    {
        AnonymousPaymentMethod payment = (AnonymousPaymentMethod)checkout.PaymentMethod;

        ProcessPaymentResult paymentResult;
        bool result = payment.ProcessPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.Configurations.GetValue("PaymentCurrency"),
            checkout,
            out paymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                checkout,
                StoreContext.Culture,
                StoreContext.Currency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP());

            OrderAmount orderAmount;
            Order       order = PlaceOrderAnonymous(
                (Page.User.Identity.IsAuthenticated) ? Membership.GetUser().UserName : SystemConst.AnonymousUser,
                orderCreateService,
                checkout, out orderAmount);

            AffiliateOrder affiliateorder = new AffiliateOrder();
            affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
            affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);
            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            CheckoutNotCompletePage.RedirectToPage(
                "Error Message",
                paymentResult.ErrorMessage,
                "ShoppingCart.aspx",
                "Return To Shopping Cart");
        }
    }
示例#12
0
    private void ProcessZeroPricePayment(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        Exception emailEx = order.SendOrderEmailNoThrow();

        StoreError.Instance.Exception = emailEx;

        order.ProcessPaymentComplete();

        StoreContext.ClearCheckoutSession();

        Response.Redirect("CheckoutComplete.aspx?OrderID=" + order.OrderID +
                          "&IsTransaction=True" + GenerateIsEmailOKString(emailEx));
    }
示例#13
0
    private void ProcessOfflinePaymentSuccess(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        // Do not send electronic goods for offline payment. Merchants should send them manually.

        //********************* For Testing *****************************
        //order.SendDownloadEmailByOrderID();

        Exception emailEx = order.SendOrderEmailNoThrow();

        StoreError.Instance.Exception = emailEx;

        StoreContext.ClearCheckoutSession();

        MainContext.RedirectMainControl("OrdersEdit.ascx", String.Format("OrderID={0}", order.OrderID));
    }
示例#14
0
    private void ProcessHostedPayment(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        PaymentAppGateway gateway = new PaymentAppGateway(checkout);

        string xmlData = gateway.CreateHostedPaymentXml(
            StoreContext.Culture,
            CurrenntCurrency,
            StoreContext.ShoppingCart,
            UrlPath.StorefrontUrl,
            order.OrderID,
            StoreContext.GetOrderAmount().Total,
            StoreContext.WholesaleStatus,
            WebUtilities.GetVisitorIP());

        Response.Redirect("../Gateway/GatewayPosting.aspx?OrderID=" + order.OrderID);
    }
示例#15
0
    private void ProcessOfflinePaymentSuccess(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        // Do not send electronic goods for offline payment. Merchants should send them manually.

        //********************* For Testing *****************************
        //order.SendDownloadEmailByOrderID();

        Exception emailEx = order.SendOrderEmailNoThrow();

        StoreError.Instance.Exception = emailEx;

        StoreContext.ClearCheckoutSession();

        Response.Redirect("CheckoutComplete.aspx?OrderID=" + order.OrderID +
                          "&IsTransaction=True" + GenerateIsEmailOKString(emailEx));
    }
示例#16
0
    private void ProcessCreditCardPaymentSuccess(
        OrderNotifyService order,
        string gatewayOrderID,
        string log,
        string cvvStatus,
        string AvsAddrStatus,
        string AvsZipStatus
        )
    {
        if (!String.IsNullOrEmpty(log))
        {
            PaymentLog paymentLog = new PaymentLog();
            paymentLog.OrderID         = order.OrderID;
            paymentLog.PaymentResponse = log;
            paymentLog.PaymentGateway  = order.PaymentMethod;
            paymentLog.PaymentType     = "ProcessCreditCard";
            DataAccessContext.PaymentLogRepository.Save(paymentLog);
        }

        if (!String.IsNullOrEmpty(gatewayOrderID) ||
            !String.IsNullOrEmpty(cvvStatus) ||
            !String.IsNullOrEmpty(AvsAddrStatus) ||
            !String.IsNullOrEmpty(AvsZipStatus))
        {
            Order orderDetails = DataAccessContext.OrderRepository.GetOne(order.OrderID);
            orderDetails.GatewayOrderID = gatewayOrderID;
            orderDetails.CvvStatus      = cvvStatus;
            orderDetails.AvsAddrStatus  = AvsAddrStatus;
            orderDetails.AvsZipStatus   = AvsZipStatus;
            DataAccessContext.OrderRepository.Save(orderDetails);
        }

        Exception emailEx = order.SendOrderEmailNoThrow();

        StoreError.Instance.Exception = emailEx;

        order.ProcessPaymentComplete();

        StoreContext.ClearCheckoutSession();

        Response.Redirect("CheckoutComplete.aspx?OrderID=" + order.OrderID +
                          "&IsTransaction=True" + GenerateIsEmailOKString(emailEx));
    }
示例#17
0
    private void ProcessRecurringPayment()
    {
        try
        {
            Log.Debug(" ----- Start ProcessRecurringPayment() ----- ");
            Log.Debug(" PaymentStatus : " + PaymentStatus);

            String orderID = "";
            if (PaymentStatus == "Completed")
            {
                Log.Debug("++++++++++ Enter CreateChildOrderByPayPalRefenceID ++++++++++");
                int allSequence;
                orderID = PayPalProUSPaymentMethod.CreateChildOrderByPayPalRefenceID(
                    RecurringReferenceID,
                    RecurringAmount,
                    RecurringStatus,
                    PaymentStatus,
                    ReceiptID,
                    PeriodType,
                    DateTime.Now,
                    out allSequence);
                Log.Debug("++++++++++ End CreateChildOrderByPayPalRefenceID ++++++++++");

                Log.Debug(" OrderID : " + orderID);
                Log.Debug(" RecurringReferenceID : " + RecurringReferenceID);
                Log.Debug(" RecurringAmount : " + RecurringAmount);
                Log.Debug(" RecurringStatus : " + RecurringStatus);
                Log.Debug(" PaymentStatus : " + PaymentStatus);
                Log.Debug(" ReceiptID : " + ReceiptID);
                Log.Debug(" PeriodType : " + PeriodType);
                Log.Debug(" allSequence : " + allSequence);

                if (!String.IsNullOrEmpty(orderID))
                {
                    if (allSequence > 1)
                    {
                        Log.Debug(" Enter AllSequence > 1");
                        OrderNotifyService order = new OrderNotifyService(orderID);
                        order.SendOrderEmail();
                        Log.Debug(" SendOrderEmail() ");
                        Log.Debug(" End AllSequence > 1");
                    }
                    else if (allSequence == 1)
                    {
                        Log.Debug(" Enter AllSequence == 1");

                        string recurringID =
                            DataAccessContext.RecurringProfileRepository.GetRecurringIDFromReferenceID(
                                RecurringReferenceID);
                        RecurringProfile recurringProfile =
                            DataAccessContext.RecurringProfileRepository.GetOne(recurringID);

                        Log.Debug(" RecurringID : " + recurringID);

                        recurringProfile.RecurringStatus = SystemConst.RecurringStatus.Ongoing.ToString();
                        recurringProfile.UpdateTime      = DateTime.Now;
                        DataAccessContext.RecurringProfileRepository.Save(recurringProfile);

                        bool isAllRecurringPaymentComplete = true;

                        IList <OrderItem> orderItemList = DataAccessContext.OrderItemRepository.GetByOrderID(orderID);

                        Log.Debug(" OrderItemList : " + orderItemList.Count);
                        int count = 0;
                        foreach (OrderItem item in orderItemList)
                        {
                            Log.Debug(" Count : " + count);
                            Log.Debug(" item.RecurringID : " + item.RecurringID);
                            if (item.RecurringID != "0")
                            {
                                recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(item.RecurringID);

                                Log.Debug(" RecurringProfile.RecurringStatus : " + recurringProfile.RecurringStatus);

                                if (recurringProfile.RecurringStatus != SystemConst.RecurringStatus.Ongoing.ToString() &&
                                    recurringProfile.RecurringStatus != SystemConst.RecurringStatus.Expired.ToString())
                                {
                                    Log.Debug("RecurringStatus != Ongoing && RecurringStatus != Expired");
                                    isAllRecurringPaymentComplete = false;
                                    Log.Debug(" Break;");
                                    break;
                                }
                            }
                            count++;
                        }

                        Log.Debug("isAllRecurringPaymentComplete :" + isAllRecurringPaymentComplete);

                        if (isAllRecurringPaymentComplete)
                        {
                            Log.Debug(" Enter AllRecurringPaymentComplete");
                            Order orderDetails = DataAccessContext.OrderRepository.GetOne(orderID);

                            orderDetails.PaymentComplete = true;
                            DataAccessContext.OrderRepository.Save(orderDetails);
                            Log.Debug(" Exit AllRecurringPaymentComplete");
                        }
                        Log.Debug(" End AllSequence == 1");
                    }

                    if (RecurringStatus == SystemConst.RecurringStatus.Expired.ToString())
                    {
                        Log.Debug(" Enter Expired Recurring Status");

                        string recurringID =
                            DataAccessContext.RecurringProfileRepository.GetRecurringIDFromReferenceID(
                                RecurringReferenceID);
                        RecurringProfile recurringProfile =
                            DataAccessContext.RecurringProfileRepository.GetOne(recurringID);
                        recurringProfile.RecurringStatus = SystemConst.RecurringStatus.Expired.ToString();
                        recurringProfile.UpdateTime      = DateTime.Now;
                        DataAccessContext.RecurringProfileRepository.Save(recurringProfile);

                        Log.Debug(" RecurringStatus : " + recurringProfile.RecurringStatus);
                        Log.Debug(" UpdateTime : " + DateTime.Now.ToString());
                        Log.Debug(" End Expired Recurring Status");
                    }
                }
                else
                {
                    PaymentLog paymentLog = new PaymentLog();
                    paymentLog.OrderID         = "0";
                    paymentLog.PaymentResponse = Request.Form.ToString();
                    paymentLog.PaymentGateway  = GetPaymentName();
                    paymentLog.PaymentType     = "PayPalRecurringPaymentFailedByNullOrderID";
                    DataAccessContext.PaymentLogRepository.Save(paymentLog);

                    Log.Debug("OrderID : " + orderID);
                    Log.Debug("PaymentResponse : " + Request.Form.ToString());
                    Log.Debug("PaymentGateway : " + GetPaymentName());
                    Log.Debug("PaymentType : " + paymentLog.PaymentType);
                }
            }
            else
            {
                PaymentLog paymentLog = new PaymentLog();
                paymentLog.OrderID         = orderID;
                paymentLog.PaymentResponse = Request.Form.ToString();
                paymentLog.PaymentGateway  = GetPaymentName();
                paymentLog.PaymentType     = "PayPalRecurringPaymentNotCompleted";
                DataAccessContext.PaymentLogRepository.Save(paymentLog);

                Log.Debug("OrderID : " + orderID);
                Log.Debug("PaymentResponse : " + Request.Form.ToString());
                Log.Debug("PaymentGateway : " + GetPaymentName());
                Log.Debug("PaymentType : " + paymentLog.PaymentType);
            }
            Log.Debug(" ----- End ProcessRecurringPayment() ----- ");
        }
        catch (Exception ex)
        {
            Log.Debug("    ***** Start ProcessRecurringPayment() Exception ***** ");
            PaymentLog paymentLog = new PaymentLog();
            paymentLog.OrderID         = "0";
            paymentLog.PaymentResponse = Request.Form.ToString() + "&Exception:" + ex.Message;
            paymentLog.PaymentGateway  = GetPaymentName();
            paymentLog.PaymentType     = "PayPalRecurringPaymentFailed";
            DataAccessContext.PaymentLogRepository.Save(paymentLog);

            Log.Debug(" Error : " + ex);
            Log.Debug("    ***** End ProcessRecurringPayment() Exception ***** ");
            Log.Debug(" ----- End ProcessRecurringPayment() ----- ");
        }
    }
示例#18
0
    private void UpdateOrder()
    {
        Order order = DataAccessContext.OrderRepository.GetOne(CurrentOrderID);

        order.OrderDate = GetOrderDate(GetCalendarDate("uxOrderDateCalendarPopup"));
        order.UserName  = GetText("uxUserNameText");
        order.Billing   = new Address(GetText("uxFirstNameText"), GetText("uxLastNameText"),
                                      GetText("uxCompanyText"), GetText("uxAddress1Text"), GetText("uxAddress2Text"),
                                      GetText("uxCityText"), GetStateList("uxStateList"), GetText("uxZipText"),
                                      GetCountryList("uxCountryList"), GetText("uxPhoneText"), GetText("uxFaxText"));
        order.Email    = GetText("uxEmailText");
        order.Shipping = new ShippingAddress(
            new Address(GetText("uxShippingFirstNameText"), GetText("uxShippingLastNameText"),
                        GetText("uxShippingCompanyText"), GetText("uxShippingAddress1Text"),
                        GetText("uxShippingAddress2Text"), GetText("uxShippingCityText"),
                        GetStateList("StateListShipping"), GetText("uxShippingZipText"),
                        GetCountryList("CountryListShipping"), GetText("uxShippingPhoneText"),
                        GetText("uxShippingFaxText")),
            false);
        order.PaymentMethod       = GetText("uxPaymentMethodText");
        order.ShippingMethod      = GetText("uxShippingMethodText");
        order.PaymentComplete     = GetCheck("uxPaymentCompleteCheck");
        order.Processed           = GetCheck("uxProcessedCheck");
        order.Status              = GetDrop("uxStatusDrop");
        order.Cancelled           = GetCheck("uxCancelledCheck");
        order.IPAddress           = GetText("uxIPAddressText");
        order.Subtotal            = DataAccessContext.OrderItemRepository.GetSubtotal(CurrentOrderID);
        order.Tax                 = ConvertUtilities.ToDecimal(GetText("uxTaxText"));
        order.ShippingCost        = ConvertUtilities.ToDecimal(GetText("uxShippingCostText"));
        order.CouponID            = GetText("uxCouponIDText");
        order.CouponDiscount      = ConvertUtilities.ToDecimal(GetText("uxCouponDiscountText"));
        order.CustomerComments    = GetText("uxCommentText");
        order.BaseCurrencyCode    = GetText("uxBaseCodeText");
        order.UserCurrencyCode    = GetText("uxUserCurrencyCodeText");
        order.UserConversionRate  = ConvertUtilities.ToDouble(GetText("uxConversionRateText"));
        order.InvoiceNotes        = GetText("uxInvoiceNotesText");
        order.GiftCertificateCode = GetText("uxGiftCertificateCodeText");
        order.GiftCertificate     = ConvertUtilities.ToDecimal((GetText("uxGiftCertificateText")));
        order.TrackingNumber      = GetText("uxTrackingNumerText");
        order.TrackingMethod      = GetDrop("uxTrackingMethodDrop");
        order.HandlingFee         = ConvertUtilities.ToDecimal(GetText("uxHandlingFeeText"));
        order.ContainsRecurring   = IsOrderContainRecurring();
        order.AvsAddrStatus       = ((DropDownList)uxFormView.Row.FindControl("uxAvsAddrDrop")).SelectedValue;
        order.AvsZipStatus        = ((DropDownList)uxFormView.Row.FindControl("uxAvsZipDrop")).SelectedValue;
        order.CvvStatus           = ((DropDownList)uxFormView.Row.FindControl("uxCvvDrop")).SelectedValue;
        order.PONumber            = GetText("uxPONumberText");

        if (IsSaleTaxExemptVisible(true) && !String.IsNullOrEmpty(GetText("uxTaxExepmtIDText")))
        {
            order.IsTaxExempt      = true;
            order.TaxExemptID      = GetText("uxTaxExepmtIDText");
            order.TaxExemptCountry = GetCountryList("uxTaxExemptCountryList");
            order.TaxExemptState   = GetStateList("uxTaxExemptStateList");
        }
        else
        {
            order.IsTaxExempt      = false;
            order.TaxExemptID      = String.Empty;
            order.TaxExemptCountry = String.Empty;
            order.TaxExemptState   = String.Empty;
        }

        DataAccessContext.OrderRepository.Save(order);
        if (order.PaymentComplete)
        {
            CustomerRewardPoint.UpdateRewardPoint(order);

            if (!order.IsSubscriptionApplied)
            {
                OrderNotifyService orderNotifyService = new OrderNotifyService(order.OrderID);
                orderNotifyService.UpdateCustomerSubscription(order);
                order.IsSubscriptionApplied = true;
                DataAccessContext.OrderRepository.Save(order);
            }
        }
    }
示例#19
0
    private void ProcessIntegratedTwoCheckoutPayment(CheckoutDetails checkout)
    {
        OrderNotifyService order = CreateOrder(checkout);

        Response.Redirect("Gateway/GatewayTwoCheckoutPost.aspx?OrderID=" + order.OrderID);
    }
示例#20
0
    private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout)
    {
        PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod;
        bool                   result          = false;
        PaymentAppResult       paymentResult;
        RecurringPaymentResult recurringPaymentResult;
        ProcessPaymentService  process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart);

        result = process.ProcessPayPalProUSPayment(
            StoreContext.GetOrderAmount().Total,
            DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")),
            StoreContext.Culture,
            checkout,
            StoreContext.ShoppingCart,
            StoreContext.Customer,
            UrlPath.StorefrontUrl,
            WebUtilities.GetVisitorIP(),
            out paymentResult,
            out recurringPaymentResult);

        if (result)
        {
            OrderCreateService orderCreateService = new OrderCreateService(
                StoreContext.ShoppingCart,
                StoreContext.CheckoutDetails,
                StoreContext.Culture,
                StoreContext.Currency,
                AffiliateHelper.GetAffiliateCode(),
                WebUtilities.GetVisitorIP(),
                recurringPaymentResult
                );

            Order       order;
            OrderAmount orderAmount;
            if (!IsAnonymousCheckout())
            {
                order = PlaceOrder(orderCreateService, out orderAmount);
            }
            else
            {
                order = PlaceOrderAnonymous(SystemConst.UnknownUser, orderCreateService, checkout, out orderAmount);
            }

            AffiliateOrder affiliateorder = new AffiliateOrder();
            affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
            affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

            OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID);

            ProcessCreditCardPaymentSuccess(
                orderBusiness,
                paymentResult.GatewayOrderID,
                paymentResult.PaymentLog,
                paymentResult.CvvStatus,
                paymentResult.AvsAddrStatus,
                paymentResult.AvsZipStatus);
        }
        else
        {
            ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Extract the XML from the request.
        Stream       RequestStream       = Request.InputStream;
        StreamReader RequestStreamReader = new StreamReader(RequestStream);
        string       RequestXml          = RequestStreamReader.ReadToEnd();

        RequestStream.Close();
        Log.Debug("Request XML:\n" + RequestXml);

        string             gatewayOrderID = "";
        string             orderID;
        OrderNotifyService orderBusiness;

        try
        {
            // Act on the XML.
            switch (EncodeHelper.GetTopElement(RequestXml))
            {
            case "new-order-notification":
                Log.Debug("Start new-order-notification");
                NewOrderNotification N1 =
                    (NewOrderNotification)EncodeHelper.Deserialize(RequestXml,
                                                                   typeof(NewOrderNotification));
                string OrderNumber1 = N1.googleordernumber;

                PaymentLogUpdateNewOrderNotification(N1);
                _serialNumber = N1.serialnumber;
                Log.Debug("-********************- Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-");
                Log.Debug("GetOrderIDByGateWayID ( "
                          + OrderNumber1 + " ) = " + DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1));
                Log.Debug("-********************- END Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-");
                if (DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1) == "0")
                {
                    BuildShoppingCart(RequestXml, N1);

                    Log.Debug("Start converting to order");

                    OrderCreateService orderCreateService = new OrderCreateService(
                        StoreContext.ShoppingCart,
                        StoreContext.CheckoutDetails,
                        StoreContext.Culture,
                        StoreContext.Currency,
                        AffiliateHelper.GetAffiliateCode(),
                        WebUtilities.GetVisitorIP());

                    string storeID = EncodeHelper.GetElementValue(RequestXml, "StoreID");
                    DataAccessContext.SetStoreRetriever(new StoreRetriever(storeID));

                    OrderAmount orderAmount = orderCreateService.GetOrderAmount(Customer.Null)
                                              .Add(CartItemPromotion.CalculatePromotionShippingAndTax(
                                                       StoreContext.CheckoutDetails,
                                                       StoreContext.ShoppingCart.SeparateCartItemGroups(),
                                                       Customer.Null));

                    Order order = orderCreateService.PlaceOrderAnonymous(orderAmount,
                                                                         SystemConst.UnknownUser,
                                                                         CreateBuyerBillingAddress(N1),
                                                                         ConvertToString(N1.buyerbillingaddress.email), DataAccessContext.StoreRetriever, StoreContext.Culture);

                    AffiliateOrder affiliateorder = new AffiliateOrder();
                    affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode();
                    affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount);

                    orderBusiness = new OrderNotifyService(order.OrderID);

                    Log.Debug("End converting to order");

                    Log.Debug("Start sending order email");
                    orderBusiness.SendOrderEmail();
                    Log.Debug("End sending order email");

                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(order.OrderID);
                    orderDetail.GatewayOrderID = OrderNumber1;
                    Log.Debug("OrderDetail.GatewayOrderID = " + OrderNumber1);
                    Log.Debug("Start Save Order Detail");
                    DataAccessContext.OrderRepository.Save(orderDetail);
                    Log.Debug("End Save Order Detail");

                    DataAccessContext.SetStoreRetriever(new StoreRetriever());
                }
                else
                {
                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(
                        DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1));

                    Log.Debug("-**************************- start Check Error -**************************-");
                    Log.Debug("N1.googleOrderNumber = " + N1.googleordernumber);
                    Log.Debug("OrderNumber1 = " + OrderNumber1);
                    Log.Debug("N1.buyerbillingaddress.contactname = " + ConvertToString(N1.buyerbillingaddress.contactname));
                    Log.Debug("N1.buyerbillingaddress.address1 = " + ConvertToString(N1.buyerbillingaddress.address1));
                    Log.Debug("N1.buyerbillingaddress.city = " + ConvertToString(N1.buyerbillingaddress.city));
                    Log.Debug("N1.buyerbillingaddress.region = " + ConvertToString(N1.buyerbillingaddress.contactname));
                    Log.Debug("N1.buyerbillingaddress.postalcode = " + ConvertToString(N1.buyerbillingaddress.postalcode));
                    Log.Debug("orderDetail.Billing.Company = " + orderDetail.Billing.Company);
                    Log.Debug("orderDetail.Billing.Country = " + orderDetail.Billing.Country);
                    Log.Debug("orderDetail.Billing.Phone = " + orderDetail.Billing.Phone);
                    Log.Debug("orderDetail.Billing.Fax = " + orderDetail.Billing.Fax);
                    Log.Debug("-**************************- End Check Error -**************************-");

                    orderDetail.Billing = new Vevo.Base.Domain.Address(ConvertToString(N1.buyerbillingaddress.contactname),
                                                                       String.Empty, orderDetail.Billing.Company,
                                                                       ConvertToString(N1.buyerbillingaddress.address1),
                                                                       ConvertToString(N1.buyerbillingaddress.address2),
                                                                       ConvertToString(N1.buyerbillingaddress.city),
                                                                       ConvertToString(N1.buyerbillingaddress.region),
                                                                       ConvertToString(N1.buyerbillingaddress.postalcode),
                                                                       orderDetail.Billing.Country, orderDetail.Billing.Phone,
                                                                       orderDetail.Billing.Fax);
                    orderDetail.Email = ConvertToString(N1.buyerbillingaddress.email);

                    DataAccessContext.OrderRepository.Save(orderDetail);
                }

                Log.Debug("End new-order-notification");
                break;

            case "risk-information-notification":
                Log.Debug("risk-information-notification");
                RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(RiskInformationNotification));
                // This notification tells us that Google has authorized the order
                // and it has passed the fraud check.
                // Use the data below to determine if you want to accept the order, then start processing it.
                gatewayOrderID = N2.googleordernumber;
                _serialNumber  = N2.serialnumber;

                PaymentLogUpdateRiskInformation(N2);
                VerifyAvsAndCvv(N2);
                break;

            case "order-state-change-notification":
                Log.Debug("Start order-state-change-notification");
                OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(OrderStateChangeNotification));

                _serialNumber = N3.serialnumber;

                PaymentLogUpdateOrderStateChange(N3);

                if (N3.newfinancialorderstate != N3.previousfinancialorderstate)
                {
                    Order orderDetail = DataAccessContext.OrderRepository.GetOne(
                        DataAccessContext.OrderRepository.GetOrderIDByGatewayID(N3.googleordernumber));
                    orderDetail.GatewayPaymentStatus = N3.newfinancialorderstate.ToString();

                    DataAccessContext.OrderRepository.Save(orderDetail);

                    switch (N3.newfinancialorderstate)
                    {
                    case FinancialOrderState.PAYMENT_DECLINED:
                    case FinancialOrderState.CANCELLED_BY_GOOGLE:
                        SendErrorEmail(N3);
                        break;

                    case FinancialOrderState.CHARGEABLE:
                        if (DataAccessContext.Configurations.GetBoolValueNoThrow("GCheckoutChargeAuto"))
                        {
                            GoogleChargeOrder(N3.googleordernumber);
                        }
                        break;
                    }
                }

                Log.Debug("End order-state-change-notification");
                break;

            case "charge-amount-notification":
                Log.Debug("Start charge-amount-notification");
                ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(RequestXml,
                                                                                                 typeof(ChargeAmountNotification));
                // Google has successfully charged the customer's credit card.
                gatewayOrderID = N4.googleordernumber;
                _serialNumber  = N4.serialnumber;

                PaymentLogChargeAmountUpdate(N4);

                orderID       = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID);
                orderBusiness = new OrderNotifyService(orderID);
                orderBusiness.ProcessPaymentComplete();
                Log.Debug("End charge-amount-notification");
                break;

            case "refund-amount-notification":
                Log.Debug("Start refund-amount-notification");

                RefundAmountNotification N5 =
                    (RefundAmountNotification)EncodeHelper.Deserialize(
                        RequestXml,
                        typeof(RefundAmountNotification));
                // Google has successfully refunded the customer's credit card.
                gatewayOrderID = N5.googleordernumber;
                _serialNumber  = N5.serialnumber;
                //decimal RefundedAmount = N5.latestrefundamount.Value;

                PaymentLogUpdateRefundAmount(N5);
                Order orderDetails = DataAccessContext.OrderRepository.GetOne(
                    DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID));
                orderDetails.PaymentComplete = false;
                DataAccessContext.OrderRepository.Save(orderDetails);

                Log.Debug("End refund-amount-notification");
                break;

            case "chargeback-amount-notification":
                Log.Debug("Start chargeback-amount-notification");

                ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize(
                    RequestXml, typeof(ChargebackAmountNotification));
                // A customer initiated a chargeback with his credit card company to get her money back.
                gatewayOrderID = N6.googleordernumber;
                _serialNumber  = N6.serialnumber;
                decimal ChargebackAmount = N6.latestchargebackamount.Value;

                PaymentLogUpdateChargeback(N6);

                orderDetails = DataAccessContext.OrderRepository.GetOne(
                    DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID));
                orderDetails.GatewayPaymentStatus = "ChargeBack";
                DataAccessContext.OrderRepository.Save(orderDetails);

                Log.Debug("End chargeback-amount-notification");
                break;

            default:
                break;
            }
        }
        catch (Exception ex)
        {
            DataAccessContext.SetStoreRetriever(new StoreRetriever());
            Log.Debug(ex.ToString());
        }
    }