首页 > 解决方案 > PayPal API 购物车和 Webhooks?

问题描述

我使用 PayPal 按钮代码生成器创建了 2 个按钮。

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="business" value="sb-3ghgk675036@business.example.com">
    <input type="hidden" name="lc" value="US">
    <input type="hidden" name="item_name" value="TestName">
    <input type="hidden" name="item_number" value="TestID">
    <input type="hidden" name="amount" value="50.00">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="button_subtype" value="products">
    <input type="hidden" name="no_note" value="0">
    <input type="hidden" name="tax_rate" value="0.000">
    <input type="hidden" name="shipping" value="0.00">
    <input type="hidden" name="add" value="1">
    <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit"
        alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="business" value="ZAH44BSSBQT6G">
    <input type="hidden" name="display" value="1">
    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_viewcart_LG.gif" border="0" name="submit"
        alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

我需要知道是否可以传递应用程序 client_id 而不是(我的业务电子邮件或商家 ID),以便我可以使用这些按钮触发我的服务器上的 Webhook?如果不可能,是否有任何方法可以将 paypal 购物车与 REST API webhook 一起使用?

标签: phpwordpresspaypalpaypal-rest-sdkpaypal-webhooks

解决方案


你为什么要使用那个超级旧、丑陋的 web 1.0 购物车?这是一个遗留的东西,只为了向后兼容旧网站而存在。您应该实现自己的 JS 购物车并改用智能支付按钮:https ://developer.paypal.com/demo/checkout/#/pattern/client

无论如何,如果您确实坚持使用旧的 web 1.0 集成并希望将其与 webhook 结合使用,请尝试订阅所有可能的付款捕获/完成 webhook 事件(v1 和 v2)并查看您收到的内容。如果您什么也没收到,您将需要使用旧的即时付款通知 (IPN) 服务而不是 webhook。


推荐阅读