Search code examples
phpwordpresspaypalpaypal-rest-sdkpaypal-webhooks

PayPal API shopping cart and Webhooks?


I have created 2 buttons using the PayPal buttons code generator.

  • Add to cart
<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="[email protected]">
    <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>

  • View cart
<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>

I need to know if it is possible to pass the App client_id instead of (my business email or merchant_id) so that I can trigger the Webhooks on my server with these buttons? If it is not possible is there any way to use the paypal shopping cart with REST API webhooks?


Solution

  • Why are you using that super-old, ugly, web 1.0 shopping cart? It's a legacy thing that exists only for backwards compatibility with old websites. You should implement your own JS shopping cart and use Smart Payment Buttons instead: https://developer.paypal.com/demo/checkout/#/pattern/client

    Anyway, if you do insist on using an old web 1.0 integration and want to combine this with webhooks, try subscribing to all possible payment capture/completion webhook events (both v1 and v2) and see what you receive. If you receive nothing, you will need to use the old Instant Payment Notification (IPN) service instead of webhooks.