通过 PayPal 传递选项

发布于 2024-11-13 05:56:07 字数 2447 浏览 4 评论 0原文

我正在为客户创建一个简单的结帐,访问者可以通过 PayPal 结帐。目前,我的 HTML 表单如下所示:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
  <fieldset> 
    <input type="hidden" name="cmd" value="_xclick" /> 
    <input type="hidden" name="business" value="[email protected]" /> 
    <input type="hidden" name="item_number" value="29" /> 
    <input type="hidden" name="amount" value="17.99" /> 
    <input type="hidden" name="currency_code" value="GBP" /> 
    <input type="hidden" name="lc" value="GB" /> 
    <input type="hidden" name="item_name" value="Cohda Design Limited: Design Filter Tee" /> 
    <dl id="product_options"> 
      <dt><label for="option_selection1">T-shirt size:</label></dt> 
      <dd> 
        <input type="hidden" name="option_name1" value="T-shirt size" /> 
        <select name="option_selection1" id="option_selection1"> 
          <option value="Small">Small</option> 
          <option value="Medium">Medium</option> 
          <option value="Large">Large</option> 
          <option value="Extra Large">Extra Large</option> 
        </select> 
      </dd> 
      <dt><label for="option_selection2">T-shirt colour:</label></dt> 
      <dd> 
        <input type="hidden" name="option_name2" value="T-shirt colour" /> 
        <select name="option_selection2" id="option_selection2"> 
          <option value="Machine Gun Grey">Machine Gun Grey</option> 
          <option value="Blood Red">Blood Red</option> 
        </select> 
      </dd> 
    </dl> 
    <label for="quantity">Quantity:</label> 
    <input type="text" name="quantity" value="1" id="quantity" class="numeric" size="2" maxlength="2" /> 
    <input type="submit" value="Buy now with PayPal or credit/debit card" class="button" /> 
  </fieldset> 
</form> 

如您所见,这是一个将产品详细信息传递到 PayPal 进行结账的简单表单。但是,我在自定义选项(即 option_name1option_selection1 等)方面遇到问题。

如何将所选尺寸和颜色等自定义信息传递给 PayPal 供客户和管理员查看?目前,使用 PayPal 沙箱功能测试上述内容,我看不到任何与自定义选项相关的内容。

I'm creating a simple checkout for a client where the visitor can check out via PayPal. Currently, my HTML form looks like this:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
  <fieldset> 
    <input type="hidden" name="cmd" value="_xclick" /> 
    <input type="hidden" name="business" value="[email protected]" /> 
    <input type="hidden" name="item_number" value="29" /> 
    <input type="hidden" name="amount" value="17.99" /> 
    <input type="hidden" name="currency_code" value="GBP" /> 
    <input type="hidden" name="lc" value="GB" /> 
    <input type="hidden" name="item_name" value="Cohda Design Limited: Design Filter Tee" /> 
    <dl id="product_options"> 
      <dt><label for="option_selection1">T-shirt size:</label></dt> 
      <dd> 
        <input type="hidden" name="option_name1" value="T-shirt size" /> 
        <select name="option_selection1" id="option_selection1"> 
          <option value="Small">Small</option> 
          <option value="Medium">Medium</option> 
          <option value="Large">Large</option> 
          <option value="Extra Large">Extra Large</option> 
        </select> 
      </dd> 
      <dt><label for="option_selection2">T-shirt colour:</label></dt> 
      <dd> 
        <input type="hidden" name="option_name2" value="T-shirt colour" /> 
        <select name="option_selection2" id="option_selection2"> 
          <option value="Machine Gun Grey">Machine Gun Grey</option> 
          <option value="Blood Red">Blood Red</option> 
        </select> 
      </dd> 
    </dl> 
    <label for="quantity">Quantity:</label> 
    <input type="text" name="quantity" value="1" id="quantity" class="numeric" size="2" maxlength="2" /> 
    <input type="submit" value="Buy now with PayPal or credit/debit card" class="button" /> 
  </fieldset> 
</form> 

As you can see, a simply form that passes a product's details to PayPal for checkout. However, I'm having a problem with custom options, namely option_name1, option_selection1 etc.

How can I pass custom information such as selected size and colour et al to PayPal for the client—and administrator—to view? As currently, testing the above with the PayPal sandbox feature I can't see any where anything pertaining to custom options.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

许你一世情深 2024-11-20 05:56:07

option_selectX是IPN消息中的参数名称。您需要添加到按钮的是:

<input type="hidden" name="on0" value="Size">Size
<select name="os0">
<option value="Option 1">Option 1 $10.00</option>
<option value="Option 2">Option 2 $12.00</option>
<option value="Option 3">Option 3 $13.00</option>
</select>
<input type="hidden" name="option_select0" value="Option 1">
<input type="hidden" name="option_amount0" value="10.00">
<input type="hidden" name="option_select1" value="Option 2">
<input type="hidden" name="option_amount1" value="12.00">
<input type="hidden" name="option_select2" value="Option 3">
<input type="hidden" name="option_amount2" value="13.00">

只需添加“on1”和“os1”作为颜色等。
您可以创建一个静态按钮,通过https://www.paypal.com/buttonfactory<查看生成的代码/a>

option_selectX is the name of the parameter in the IPN message. What you'll want to add to the button is this:

<input type="hidden" name="on0" value="Size">Size
<select name="os0">
<option value="Option 1">Option 1 $10.00</option>
<option value="Option 2">Option 2 $12.00</option>
<option value="Option 3">Option 3 $13.00</option>
</select>
<input type="hidden" name="option_select0" value="Option 1">
<input type="hidden" name="option_amount0" value="10.00">
<input type="hidden" name="option_select1" value="Option 2">
<input type="hidden" name="option_amount1" value="12.00">
<input type="hidden" name="option_select2" value="Option 3">
<input type="hidden" name="option_amount2" value="13.00">

Just add 'on1' and 'os1' for colours, etc.
You can create a static button to have a look at the generated code through https://www.paypal.com/buttonfactory

差↓一点笑了 2024-11-20 05:56:07

我在传递自定义变量时也遇到了麻烦,并发现我犯了错误的命名约定(可能是由于过时的文档)。

我一直在尝试使用 option_name1option_selection,但这不起作用。在我发表这篇文章之后,我尝试了 option_select0option_amount0

但直到我终于找到这个页面 https://www. paypal.com/us/cgi-bin/webscr?cmd=_pdn_xclick_options_help_outside 我意识到它实际上应该是 on0 并且os0 作为选项名称和选项值变量名称。

我希望这可以节省一些人的时间!

I had trouble passing custom variables as well, and found out that it was the naming convention that I was getting wrong (probably due to outdated docs).

I had been trying to use option_name1 and option_selection, and that wasn't working. After I was this post, I tried option_select0 and option_amount0.

But it wasn't until I finally found this page https://www.paypal.com/us/cgi-bin/webscr?cmd=_pdn_xclick_options_help_outside that I realized it should really be on0 and os0 as the option name and option value variable names.

I hope this saves someone some time!

情徒 2024-11-20 05:56:07

如果我没记错的话,您所指的自定义选项只是由 PayPal 传回回调。前提是您将特定的付款与特定的订单联系起来,然后该订单将指定您需要的所有选项。

我不确定你是否可以让贝宝对他们做任何事情。

此外,我不知道它发生了多少变化,但根据我的经验,值得注意的是,PayPal 沙箱可能与真正的 PayPal 有很大不同。

If I recall correctly, the custom options you're referring to are simply passed back by PayPal to the callback. The premise being you then tie that particular payment to a particular order which would then have all the options you require specified.

I'm not sure if you can get PayPal to do anything with them their end.

Additionally, I don't know how much it has changed, but in my experience the PayPal sandbox can differ significantly from real PayPal, worth noting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文