贝宝脚本

发布于 2024-12-05 15:55:36 字数 1666 浏览 0 评论 0原文

我想在我的网站上仅使用一个添加到购物车 paypal 按钮,并使用 php 和 select 替换产品值。

<select name="select_stuff" id="select_stuff">
      <option value="0011" >Prod1</option>
      <option value="0012" >Prod2</option>
</select>


<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <input type="hidden" name="cmd2" value="_cart">
      <input type="hidden" name="business2" value="info@xxxx">
      <input type="hidden" name="lc2" value="IT">
      <input type="hidden" name="item_name2" value="Prod1">
      <input type="hidden" name="item_number2" value="0011">
      <input type="hidden" name="amount2" value="20.00">
      <input type="hidden" name="currency_code2" value="EUR">
      <input type="hidden" name="button_subtype2" value="products">
      <input type="hidden" name="no_note2" value="0">
      <input type="hidden" name="shipping2" value="0.00">
      <input type="hidden" name="add2" value="1">
      <input type="hidden" name="bn2" value="PP-ShopCartBF:btn_cart_SM.gif:NonHostedGuest">
      <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_cart_SM.gif" border="0" name="submit2" alt="PayPal - Il sistema di pagamento online pi&ugrave; facile e sicuro!">
      <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
    </form>

例如,从组合框中我选择产品 0011,然后重新加载页面,以便上面的表单将由添加到 0011 购物车的值填充,依此类推... 然后用户可以单击“添加到购物车”。

我将放置一个 switch case 以便根据 select (0011, 0012..) 的值设置表单的变量。觉得怎么样?这是一个好的方法吗?谢谢

I want to use just one add to cart paypal button for my website and substitute the product value using php and select.

<select name="select_stuff" id="select_stuff">
      <option value="0011" >Prod1</option>
      <option value="0012" >Prod2</option>
</select>


<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <input type="hidden" name="cmd2" value="_cart">
      <input type="hidden" name="business2" value="info@xxxx">
      <input type="hidden" name="lc2" value="IT">
      <input type="hidden" name="item_name2" value="Prod1">
      <input type="hidden" name="item_number2" value="0011">
      <input type="hidden" name="amount2" value="20.00">
      <input type="hidden" name="currency_code2" value="EUR">
      <input type="hidden" name="button_subtype2" value="products">
      <input type="hidden" name="no_note2" value="0">
      <input type="hidden" name="shipping2" value="0.00">
      <input type="hidden" name="add2" value="1">
      <input type="hidden" name="bn2" value="PP-ShopCartBF:btn_cart_SM.gif:NonHostedGuest">
      <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_cart_SM.gif" border="0" name="submit2" alt="PayPal - Il sistema di pagamento online più facile e sicuro!">
      <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
    </form>

For example from the combox I select the product 0011 then I reload the page so that the form above will be filled by the values for adding to the cart for 0011 and so on...
Then user can click add to cart.

i will put an switch case in order to set the variables for the form based on value of select (0011, 0012..) . What do think? Is it a good a approach? Thanks

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

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

发布评论

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

评论(1

静谧 2024-12-12 15:55:36

不,这不是一个好方法。由于您将在页面源中将要收取的金额发送到 PayPal,因此可能会导致价格被操纵。

您可以通过使用 BMCreateButton API 创建“托管按钮”来解决此问题,其中金额通过 PayPal 安全存储。但如果您已经准备使用任何 API,您不妨开始使用 PayPal Express Checkout。

Express Checkout 基于三个 API 调用; SetExpressCheckout、GetExpressCheckoutDetails 和 DoExpressCheckoutPayment。

  1. SetExpressCheckout 设置付款并返回令牌
  2. 您将买家重定向到 https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN-HERE,其中 TOKEN-HERE 是您之前收到的令牌
  3. 买家同意付款后,他会返回到您的网站。
  4. 您可以调用 GetExpressCheckoutDetails 并提供令牌作为参数来获取买家的 PAYERID。
  5. 使用提供的令牌和 PAYERID 调用 DoExpressCheckoutPayment 以完成付款

您可以在 找到 Express Checkout 的其他文档https://www.x.com/community/ppx/documentation#ec 以及 SDK 和示例代码 https://www.x.com/community/ppx/sdks#NVP

No, it's not a good approach. Since you'll be sending the amounts to be charged to PayPal clear-as-day in the source of your pages, leading possible manipulation of your prices.

You could fix this by using the BMCreateButton API to create a 'hosted button', where the amounts are securely stored with PayPal. But if you're going to be using any API's already, you may as well start using PayPal Express Checkout.

Express Checkout is based on three API calls; SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckoutPayment.

  1. SetExpressCheckout sets up the payment and returns a token
  2. You redirect the buyer to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN-HERE, where TOKEN-HERE is the token you received earlier
  3. After the buyer has agreed to the payment, he is returned back to your site.
  4. You can call GetExpressCheckoutDetails and supply the token as a parameter to get the PAYERID of the buyer.
  5. Call DoExpressCheckoutPayment with the token and PAYERID supplied to finalize the payment

You can find additional documentation for Express Checkout at https://www.x.com/community/ppx/documentation#ec as well as the SDK's and sample code at https://www.x.com/community/ppx/sdks#NVP

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