表单有多个产品Paypal

时间:2014-12-17 09:38:59

标签: html paypal

我的表格应该包含多个产品,其中包含每个产品的ID,名称和数量,但是当我将此表单发送到Paypal Sandbox时,它不会显示此信息,只有空白字段才能输入名称,您能说明应该如何这种形式看起来像?

我的表格:

            <form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
                      <input type="hidden" name="business" value="my@email.com">
                      <input type="hidden" name="cpp_header_image" value="https://mydomain.com/logo.jpg">
                      <input type="hidden" name="cmd" value="_cart">
                      <input type="hidden" name="upload" value="1">

                        <input type="hidden" name="item_number_1" value="6543">
                        <input type="hidden" name="item_name_1" value="Name of product 1">
                        <input type="hidden" name="quantity1" value="2">

                        <input type="hidden" name="item_number_2" value="1111">
                        <input type="hidden" name="item_name_2" value="Name of product 2">
                        <input type="hidden" name="quantity2" value="1">

                        <input type="hidden" name="item_number_3" value="2343">
                        <input type="hidden" name="item_name_3" value="Name of product 3">
                        <input type="hidden" name="quantity3" value="2">

                      <input type="hidden" name="invoice" value="Order ID: 1234">
                      <input type="hidden" name="amount" value="1000">                      
                      <input type="hidden" name="currency_code" value="GBP">
                      <input type="hidden" name="return" value="https://mydomain.com/">
                      <input type="hidden" name="rm" value="2">      
                      <input type="hidden" name="lc" value="EN">
                      <input type="hidden" name="bn" value="OK_BuyNow_EN">
                      <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/x-click-but6.gif" name="submit" alt="Pay with PayPal" title="Pay with PayPal">
            </form>

另外,如何通过Paypal获取付款成功与否的信息?

1 个答案:

答案 0 :(得分:0)

我只在vb.net和asp.net中知道这个,希望你可以把它转换成你需要的任何语言,但我会发布任何有机会它会帮助你。在你的paypal按钮的On_click事件中使用类似的东西。

这是我的SQL查询,它搜索到我想要的产品,因为我有1,000个产品,这允许我只拉一个并分配所有剩余的值发送到paypal

 Dim itemName As String

    Conn.Open()
    sql4.Parameters.AddWithValue("@Category", url)
    sql4.CommandText = "Select [Table] From SubCategory WHERE Category = @Category OR Type = @Category"
    sql4Str = sql4.ExecuteScalar.ToString

    sql3.Parameters.AddWithValue("@Order", testIndex)
    sql3.CommandText = ("Select * From " + sql4Str + " WHERE Order# = @Order")
    Dim cost As String
    Dim str1 As String
    Dim str2 As String       
    Dim reader As SqlDataReader = sql3.ExecuteReader
    While reader.Read()
        Str = reader.GetOrdinal("Category")
        If reader.IsDBNull(Str) Then
            Str = reader("Type")

        ElseIf Not reader.IsDBNull(Str) Then
            Str = reader("Category")
        End If
        cost = reader("Price")
        str2 = reader("Order#")

        itemName = Str
    End While

既然itemName已被分配给动态值(“Category”),我可以将itemName的值与您想要使用的任何其他值一起传递给paypal。

Dim Item As String = "Test"
Dim price As String = cost
Dim business As String = "YourEmail@email.com"
Dim itemNumber As String = str2
Dim itemAmount As String = price
Dim currencyCode As String = "USD"
Dim addItem As Integer = 1

Dim ppHref As StringBuilder = New StringBuilder()
ppHref.Append("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart")
ppHref.Append("&business=" + business)
ppHref.Append("&item_name=" + itemName)
ppHref.Append("&item_number=" + itemNumber)
ppHref.Append("&amount=" + itemAmount)
ppHref.Append("&currency_code=" + currencyCode)
ppHref.Append("&tax_rate=4")
ppHref.Append("&add=" + addItem.ToString("#0"))
Response.Redirect(ppHref.ToString(), True)
Dim ReturnQaunity As String = itemAmount
GetRouteUrl("/v1/payments/orders/<Order-Id>")

和你的paypal按钮在你的标记中就是这样的

<asp:ImageButton ID="AddToCartBtn" runat="server" RowIndex='<%# Container.DisplayIndex %>'
   ImageUrl="~/Pictures/ShoppingCart.png"                                          
  OnClick="AddToCartBtn_Click" />