public string Verify(string transactionId)
        {
            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    CommerceConfig.PayPalStandardUrl,
                    CommerceConfig.PayPalStandardEmailAddress,
                    CommerceConfig.PayPalStandardPDTId);

            gateway.TransactionId = transactionId;

            return gateway.ValidatePDT();
        }
        public string Verify(string ipnForm)
        {
            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    CommerceConfig.PayPalStandardUrl,
                    CommerceConfig.PayPalStandardEmailAddress,
                    CommerceConfig.PayPalStandardPDTId);

            gateway.IPNForm = ipnForm;

            return gateway.ValidateIPN();
        }
Esempio n. 3
0
        /// <summary>
        /// Creates hidden form fields for PayPal Standard Cart upload
        /// </summary>
        /// <returns></returns>
        public static string GetCartUploadFormFields(
            Guid payPalLogGuid,
            Cart cart,
            Store store,
            CommerceConfiguration commerceConfig)
        {
            //TODO: PayPal is not seeing discounts?

            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    commerceConfig.PayPalStandardUrl,
                    commerceConfig.PayPalStandardEmailAddress,
                    commerceConfig.PayPalStandardPDTId);

            gateway.Amount = cart.OrderTotal;
            gateway.Tax = cart.TaxTotal;
            gateway.Shipping = cart.ShippingTotal;
            gateway.CartDiscount = cart.Discount;

            //Currency currency = new Currency(cart.CurrencyGuid);
            //if (currency.Guid != Guid.Empty)
            //{
            //    gateway.CurrencyCode = currency.Code;
            //}
            //gateway.CurrencyCode = store.DefaultCurrency;
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            gateway.CurrencyCode = siteSettings.GetCurrency().Code;

            gateway.OrderHasShippableProducts = cart.HasShippingProducts();
            gateway.ShippingFirstName = cart.OrderInfo.DeliveryFirstName;
            gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName;

            gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1;
            gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2;
            gateway.ShippingCity = cart.OrderInfo.DeliveryCity;
            gateway.ShippingState = cart.OrderInfo.DeliveryState;
            gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode;

            //add the items
            foreach (CartOffer offer in cart.CartOffers)
            {
                PayPalOrderItem item = new PayPalOrderItem();
                item.Amount = offer.OfferPrice;
                item.ItemName = offer.Name;
                item.ItemNumber = offer.OfferGuid.ToString();
                item.Quantity = offer.Quantity;
                item.Tax = offer.Tax;

                gateway.Items.Add(item);

            }

            gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading;

            gateway.Custom = payPalLogGuid.ToString();

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storePageUrl = SiteUtils.GetCurrentPageUrl();

            gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx";
            gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx";
            gateway.CancelUrl = storePageUrl;

            return gateway.GetCartUploadFormFields();
        }
Esempio n. 4
0
        /// <summary>
        /// Creates the URL for PayPal Standard BuyNow button
        /// </summary>
        /// <returns></returns>
        public static string GetBuyNowUrl(
            Guid payPalLogGuid,
            Cart cart, 
            Store store,
            CommerceConfiguration commerceConfig)
        {
            //PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway();
            //gateway.PayPalStandardUrl = commerceConfig.PayPalStandardUrl;
            //gateway.BusinessEmail = commerceConfig.PayPalStandardEmailAddress;
            //gateway.PDTId = commerceConfig.PayPalStandardPDTId;

            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    commerceConfig.PayPalStandardUrl,
                    commerceConfig.PayPalStandardEmailAddress,
                    commerceConfig.PayPalStandardPDTId);

            gateway.Amount = cart.OrderTotal;
            gateway.Tax = cart.TaxTotal;
            gateway.Shipping = cart.ShippingTotal;

            //Currency currency = new Currency(cart.CurrencyGuid);
            //gateway.CurrencyCode = store.DefaultCurrency;

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            gateway.CurrencyCode = siteSettings.GetCurrency().Code;

            gateway.OrderHasShippableProducts = cart.HasShippingProducts();

            // TODO: guess we need to split this into first and last
            gateway.ShippingFirstName =  cart.OrderInfo.DeliveryFirstName;
            gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName;

            gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1;
            gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2;
            gateway.ShippingCity = cart.OrderInfo.DeliveryCity;
            gateway.ShippingState = cart.OrderInfo.DeliveryState;
            gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode;

            //add the items
            //foreach (CartOffer offer in cart.CartOffers)
            //{
            //    PayPalOrderItem item = new PayPalOrderItem();
            //    item.Amount = offer.OfferPrice;
            //    item.ItemName = offer.Name;
            //    item.ItemNumber = offer.OfferGuid.ToString();
            //    item.Quantity = offer.Quantity;

            //    gateway.Items.Add(item);

            //}

            gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading;

            gateway.Custom = payPalLogGuid.ToString();

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storePageUrl = SiteUtils.GetCurrentPageUrl();

            gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx";
            gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx";
            gateway.CancelUrl = storePageUrl;

            return gateway.GetBuyNowButtonUrl();
        }