Paypal第三方购物车

时间:2015-05-07 03:00:04

标签: php paypal checkout cart shop

我正在尝试使用paypal为我的第三方购物车创建结帐。我将所有值与paypal的网页“https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/cart_upload/”完全相同。

我从我的数据库中获取产品名称。问题是,它第一次需要它,但是当我将另一个产品添加到我的购物车并点击购买进入paypal商店页面时,它只获得了我的数据库中的一个项目。我把3个项目进行测试。

有人可以帮助我吗? 我的代码是:

<form 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="vendedortest@test.com" />

    <input type="hidden" name="item_name_1" value="<?php echo $product; ?>" />
    <input type="hidden" name="item_number_1" value="<?php echo $id; ?>" />
    <input type="hidden" name="amount_1" value="<?php echo $price; ?>" />
    <input type="hidden" name="quantity_1" value="<?php echo $qty; ?>" />

    <input type="hidden" name="currency_code" value="USD" />
    <input type="hidden" name="lc" value="US" />
    <input type="hidden" name="rm" value="2" />
    <input type="hidden" name="return" value="products.php" />
    <input type="hidden" name="cancel_return" value="cart.php" />
    <input type="hidden" name="notify_url" value="paypal.php" />
    <input type="hidden" name="charset" value="utf-8" />
</form>

1 个答案:

答案 0 :(得分:0)

我认为您混淆了两种不同的PayPal界面方法/产品,PayPal购物车(https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paypal_shopping_cart/)和PayPal的第三方购物车功能(您在问题中链接)。

PayPal购物车要求PayPal为您管理购物车,以及多个 &#34;加入购物车&#34;电话会在PayPal上逐步建立一个货车,然后您可以通过一次结账通话支付。你将cmd = _cart与函数结合起来&#34;添加&#34;或者&#34;查看&#34;修改或查看PayPal网站上的购物车,并从该PayPal托管的页面,买家可以发起结帐。

第三方结帐功能假设您的网站上有购物车,并且您正在管理从该购物车添加和删除内容;在这种情况下,只有当客户有一个完整的购物车并且想要结账时,您才会致电PayPal。在此模型中,只有最后一个PayPal表单提交是相关的 - 它会覆盖之前的所有呼叫(这将被视为中止付款)。这是设计的:用户可能会考虑购买3件东西,但返回您的网站,决定添加或删除一些商品,然后决定购买更改的购物车。当以这种方式使用时,PayPal在多次调用_cart命令之间不会保持状态。这种用法是通过使用&#34; upload&#34;来控制的。输入与_cart命令配对,如上所述。

如果您想在PayPal的购物车中放一些东西,然后在购物车中放入更多东西,然后结账,您需要切换到PayPal购物车,这意味着不使用&#34 ;上传&#34;而是使用&#34;添加&#34;命令(以及文档中指示的其他一些更改)。