Paypal rest API billing agreements webhooks
Asked Answered
I

3

12

So I am integrating the Paypal Rest API with my django site so I can introduce subscription based billing, so far everything is going great.

I have a interface for Billing plans, Billing agreements, Transaction history and everything to create and activate billing agreements ect.

However I need a way to be notified if a billing agreement is cancelled or a payment is made for a billing agreement so I though webhooks would be the way to go for this however I am not 100% sure that webhooks work for billing agreements?

Can anyone suggest a way I can track payments made for billing agreements or another method?

Inocenciainoculable answered 14/10, 2014 at 1:34 Comment(0)
E
3

I can confirm that when a recurring payment is executed, one is notified via webhook event PAYMENT.SALE.COMPLETED as described here: https://github.com/paypal/PayPal-Python-SDK/issues/132#issuecomment-261374087

JSON structure of the webhook event:

{
    ...
    "resource": {
        ...
        "billing_agreement_id": "I-38097XVV6XVU"
        ...
    }
    ...
}

A list of all event names can be found here: https://developer.paypal.com/docs/integration/direct/webhooks/event-names/

Efta answered 14/3, 2017 at 20:19 Comment(4)
could it be that in sandbox, they dont work as supposed to? I had around 20 notifications coming from different plans, and only 2 PAYMENT.SALE.COMPLETED webhooks were actually fired!Cubical
It took aways awhile until I got the webhook but it worked and it was sent from sandbox. I though was working on this at the begging of 2017. Concerning your other question, I'm not sure if you can mix APIs: creating a recurring payment using the old web forms API and registering for a webhook which is part of the REST API. In my test environment I saw that with the old web forms API one receives subscription IDs starting like "S-XXXXXX" and the ones coming from the REST API start like this "I-XXXXXX", see the example above. I think one can send test IPNs using only IPN simulator in sandbox.Efta
Jurgen, I've just tested the REST API and I got a PAYMENT.SALE.COMPLETED event 11 hours after the event creating the subscription and receiving the BILLING.SUBSCRIPTION.CREATED event. I was testing with sandbox. Unfortunately I cannot provide you any production times.Efta
Thanks. i was told that in production mode it works OK. Not sure whether I should risk it though. 11 hours doesnt seem too bad but it could be that it varies, and thats where issues startCubical
S
2

This might not be covered by paypal's webhooks notification. You can try it on sandbox and see if you get webhooks notification. Or you can use IPN, you should be able to get IPN notifications.

Scruggs answered 15/10, 2014 at 4:20 Comment(9)
Okay I test all the webhooks and I am getting nothing at all so seems as if they dont work for subscriptions which is annoying as I have done all this work for the REST API and now have to use the IPN till the REST API is ready :/Inocenciainoculable
I fully understood your situation. PayPal is actively working on REST notification solution. There's already plan to migrate users from IPN to webhooks notifications. Regarding to webhooks notification support for billing agreement, we're also working on it.Scruggs
When could we expect to see such changes made to the REST API webhooks as this is all I am waiting on to integrate the REST API into my websites billing system. And right now I am having to integrate the IPN system instead for the time being.Inocenciainoculable
@PayPalAlex, you mean to say that the officially recommended API doesn't support one of the most basic subscription features of any payment processor... and there's no obvious warning in the documentation? Add another line to the long list of reasons why every developer I've met hates paypal.Sprocket
Is there a way to query the same information IPN provides? a use case: let's say my site is down for 5 days and since IPN retries for up to 4 days, I would like to retrieve notifications I might've missed while my site was down.Give
Now, paypal webhooks and IPN are seperate, you won't be able to query IPN message through webhooks API. We're planning to release new webhooks API early next year, paypal will resend missing webhooks notifications based on time window you specified. So, the case you mentioned will be supported through webhooks.Scruggs
Related github issue on the pyhton-sdk: github.com/paypal/PayPal-Python-SDK/issues/69Marti
18 months later and still no support for billing agreements in webhooks. Looks like we're stuck using IPN, see github.com/paypal/PayPal-Python-SDK/issues/… comment on github issue that @Jason posted.Kernan
In case anyone else stumbles across this: They have finally released it: github.com/paypal/PayPal-Python-SDK/issues/132Chihuahua
A
0

At this point, it seems that webhooks are not the right way to implement Paypal Recurring Payments. This is a recent Github thread where you can see how the workflow might be: https://github.com/paypal/PayPal-REST-API-issues/issues/105

It's answered by one of the PayPal developers. Maybe we must use IPN until the webhooks development is done.

Autum answered 11/10, 2017 at 8:47 Comment(7)
but how do you set the notify_url with the IPN endpoint for the REST API? for the normal classic payments you send it as part of the request!Cubical
Hi! You have to configure it in your Paypal Developer Dashboard (developer.paypal.com).Kure
are you sure they have not removed it? I think they might have updated the portal as I can not find it. I had seen other sources referring to it, but I cannot find anything similar!Cubical
Ok, I've entered my developer dashboard to see where is it configured. First, go to the dashboard sidebar and click "My Apps & Credentials", then search "REST API apps" and create one. In its configuration you will be able to create a webhook endpoint to your controller.Kure
Yes but Webhooks and IPN are not the same thing. Read my other question to understand what I mean: #50049683Cubical
Oh, didn't read clearly. I'm sorry, I'm currently using Webhooks, I don't know how to get it working with IPN.Kure
Let us continue this discussion in chat.Cubical

© 2022 - 2024 — McMap. All rights reserved.