Exemple #1
0
 public abstract void UpdateCart(int PortalId, CartInfo Cart);
Exemple #2
0
        private void StartPaypalCheckout(string properties, int paymentProviderId)
        {
            string[] props = properties.Split(',');
            PaypalApi.UseSandbox = (props.Length == 3 || (props.Length > 3 && Convert.ToBoolean(props[3]) == true));


            PaypalUserCredentials cred = new PaypalUserCredentials(props[0], props[1], props[2]);
            PaypalSetExpressCheckoutParameters param = new PaypalSetExpressCheckoutParameters()
            {
                CancelUrl  = Globals.NavigateURL(this.TabId, "", "action=payment", "provider=" + paymentProviderId.ToString(), "result=cancel"),
                ReturnUrl  = Globals.NavigateURL(this.TabId, "", "action=payment", "provider=" + paymentProviderId.ToString(), "result=success"),
                NoShipping = 1,                                                   // PayPal does not display shipping address fields whatsoever.
                AllowNote  = 0,                                                   // The buyer is unable to enter a note to the merchant.
            };

            PaypalPaymentDetails request = new PaypalPaymentDetails();

            CartInfo cart = Controller.GetCart(PortalId, MainControl.CartId);

            request.Amt          = cart.OrderTotal + cart.AdditionalTotal + cart.OrderTax + cart.AdditionalTax;
            request.TaxAmt       = cart.OrderTax + cart.AdditionalTax;
            request.ItemAmt      = cart.OrderTotal + cart.AdditionalTotal;
            request.InvNum       = cart.CartID.ToString();
            request.CurrencyCode = "EUR";

            List <PaypalPaymentDetailsItem> items = new List <PaypalPaymentDetailsItem>();
            PaypalPaymentDetailsItem        item  = new PaypalPaymentDetailsItem();

            item.Amt  = request.ItemAmt;
            item.Name = String.Format(Localization.GetString("PPCart.Text", this.LocalResourceFile), Controller.GetStoreSettings(PortalId)["VendorName"] ?? "BBStore");
            List <CartProductInfo> products = Controller.GetCartProducts(cart.CartID);

            item.Desc = "";
            foreach (CartProductInfo product in products)
            {
                item.Desc += string.Format("{0} {1}\r\n", (product.Quantity % 1 == 0 ? (int)product.Quantity : product.Quantity), product.Name);
            }
            item.TaxAmt = request.TaxAmt;
            items.Add(item);

            string response = PaypalApi.SetExpressCheckout(cred, request, items, param);

            PaypalCommonResponse ppCommon = new PaypalCommonResponse(response);

            if (ppCommon.Ack == PaypalAckType.Success)
            {
                if (PaypalApi.UseSandbox)
                {
                    Response.Redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppCommon.Token);
                }
                else
                {
                    Response.Redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppCommon.Token);
                }
            }
            else
            {
                string message = "";
                foreach (PaypalError error in ppCommon.Errors)
                {
                    message += String.Format("ErrorNo:{0} Message {1}<br/>\r\n", error.ErrorNo, error.LongMessage);
                }
                MainControl.ErrorText += message;
            }
        }
Exemple #3
0
 public abstract void NewCart(int PortalId, CartInfo Cart);