Adding multiple items to a PayPal cart

后端 未结 2 1467
花落未央
花落未央 2021-01-14 05:34

I have created a class for PayPal that works great for adding single items however I am now trying to get this working as a cart so i can add multiple products and customise

相关标签:
2条回答
  • 2021-01-14 06:01

    I have had this same issue in the past. What I had to do was create my own cart independent of Paypal. Then, when the customer was ready to check out, I forward them to Paypal. Instead of sending multiple items and prices, I combine everything together for Paypal.

    For example if the customer orders 3 different items @ $5 each, my site would show 3 items and 3 prices. However, upen being forwarded to Paypal, the customer would see one item (ie "My Company Order") and one price (ie $15). But when returned to my site, the customer would once again see that there were 3 items ordered.

    If you are looking for a good cart system, there are literally hundreds available that support Paypal and this method.

    0 讨论(0)
  • 2021-01-14 06:11

    Hello I'm currently facing similar problem until i realize that asp.net repeater can help me resolve this.

    For example on your application interface, it must contain this ff. line of code by default (just in case you wanted your items list to be dynamic):

    <form id="Paypal" name="Paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
    method="post">
    <input type="hidden" name="cmd" value="_cart" />
    <input type="hidden" name="upload" value="1" />
    <input type="hidden" name="business" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings[" paypalemail="] %>" />
    <asp:repeater id="rptItems" runat="server" xmlns:asp="#unknown">
    <itemtemplate>
        <input type="hidden" name="item_name_<%# Eval("itemCount") %>" value="<%# Eval("itemValue") %>" />
        <input type="hidden" name="quantity_<%# Eval("itemCount") %>" value="<%# Eval("quantityValue") %>" />
        <input type="hidden" name="amount_<%# Eval("itemCount") %>" value="<%# Eval("amountValue") %>" />
    </itemtemplate>
    </asp:repeater>
    <input type="hidden" name="shipping_1" value="5" />
    <input type="hidden" name="handling_1" value="5" />
    <input type="hidden" name="tax_1" value="5" /> 
    <input type="hidden" name="currency_code" value="USD" />
    <input type="hidden" name="return" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings[" successurl="] %>" />
    <input type="hidden" name="cancel_return" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings[" failedurl="] %>" />
    <input type="hidden" name="lc" value="test lc country" />
    <input type="submit" value="Submit" />
    
    </form>
    

    whereas:

    Required Third Party Shopping Cart Variables Your HTML code requires at least the following hidden HTML variables. For a complete list of variables, see Appendix A, “HTML Variables for Website Payments Standard.” Table 4.1

    Required Third Party Shopping Cart Variables Name

    Description item_name1 - Name of a single item

    amount_1 - Price of a single item or the total price of all items in the shopping cart

    quantity_1 - Quantity of a single item

    business -
    Email address of your PayPal account

    item_name_1 - Name of the item or a name for the entire shopping cart

    upload - Indicates the use of third party shopping cart There are two ways to integrate your third party shopping cart with PayPal and Website Payments Standard:

    Pass the details of the individual items.

    Pass the aggregate amount of the total cart payment, rather than the individual item details.

    and on your code behind, you can do something like this:

    if (!Page.IsPostBack)
        {
            DataTable dtItems = new DataTable();
            dtItems.Columns.Add("itemCount");
            dtItems.Columns.Add("itemValue");
            dtItems.Columns.Add("quantityValue");
            dtItems.Columns.Add("amountValue");
            dtItems.Rows.Add("1","Cellphone", "10", "200.00");
            dtItems.Rows.Add("2", "Bag", "2", "250.00");
            dtItems.Rows.Add("3", "Mouse", "10", "3500.00");
            dtItems.Rows.Add("4", "Keyboard", "5", "200.00");
    
            rptItems.DataSource = dtItems;
            rptItems.DataBind();
       }
    

    and holla! you'll get this result when you redirect to sandbox: Paypal_capture

    Hope this post answered your concern. :) :)

    0 讨论(0)
提交回复
热议问题