FundedByMe / django-paypal-adaptive

Paypal Adaptive API support for Django
29 stars 31 forks source link

IPNs should generate signals #8

Open tarkatronic opened 10 years ago

tarkatronic commented 10 years ago

I have several cases where I need to perform actions upon receiving an IPN response, but I'm finding it somewhat difficult at the moment.

While I could attach to the individual model post_save signals (Preapproval, for instance) and figure out from there what state the instance is in, I would much prefer to simply listen to a signal such as "preapproval_approved", "preapproval_canceled" etc. so that I don't need to duplicate any logic for figuring out the state.

My primary use case for this is at the moment: When a user signs up on our site, we don't want their account to be active until they have a valid preapproval. However, there are some cases where PayPal doesn't respond immediately (or at all) with an IPN. We also need to be able to deactivate their account when an IPN is canceled.

antonagestam commented 10 years ago

@tarkatronic I think that makes sense. At fundedbyme I think we had listeners on the preapproval model that figured out what the state change was.

tarkatronic commented 10 years ago

That was suggested here as a possible way to handle it, and I did consider that solution. As I mentioned above though, I would rather not duplicate the logic for state determination. If the library is already figuring that out, why should I do it myself? It also seems somewhat more future proof to me; just in case the workings of this part of the library change in some way, I won't need to update my code to reflect those changes.