Search code examples
paypal-ipnpaypal-subscriptions

No response from IPN after payment (sandbox)


I'm trying to create a Subscription using a PayPal subscription button. I've included the following in my checkout page:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="business" value="my_merch_id"> 
<input type="hidden" name="cmd" value="_xclick-subscriptions"> 
<input type="hidden" name="item_name" value="Safe Driving Habit-Builder - Annual"> 
<input type="hidden" name="item_number" value="L43-A"> 
<input type="hidden" name="currency_code" value="USD"> 
<input type="hidden" name="a3" value="10.00"> 
<input type="hidden" name="p3" value="12"> 
<input type="hidden" name="t3" value="M"> 
<input type="hidden" name="src" value="1"> 
<input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> 
<img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > 
</form>

This seems to work but when I purchase the subscription, I don't get any feedback in the IPN handler I've set up in the Sandbox developer account. I also don't have any other way to know the purchase was successful or not. I have the .Net IPN handler code in the debugger using Visual Studio but it never gets hit. On the https://www.sandbox.paypal.com/merchantnotification/ipn/preference page, I can see my IPN handler is defined with the proper url and it says "Message Delivery: Enabled"

When I use the IPN simulator, I catch the transaction in the debugger. On the simulator page, it says "IPN was sent and the handshake was verified."

So, there are a number of questions I have about this:

  1. Why is the IPN handler not being called, am I missing something (primary)
  2. Shouldn't there be a link to a URL if subscription is cancelled
  3. Is there a link for a successful transaction?
  4. Should I be using something else, I've seen something about Smart Buttons with entirely different code. Is the button I'm using being phased out?

EDIT: So, I got some great advice from Preston and here's the new Subscription button made in the sandbox:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="cmd" value="_s-xclick" />
    <input type="hidden" name="hosted_button_id" value="xxxxx" />
    <input type="hidden" name="currency_code" value="USD" />
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_SM.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Subscribe" />
  </form>

Solution

  • paypal.com/cgi-bin/webscr HTML-only buttons and IPN are both extremely old and should be practically deprecated by now, no reason to use either.

    Instead generate a smart button via https://www.sandbox.paypal.com/billing/plans , and then in the application with the same client ID (using either the app management interface or the webhooks API), register a webhook event listener URL for at least the event PAYMENT.SALE.COMPLETED, which is the only one of importance for subscriptions (all your logic can be based on just this webhook event)