Subscriptions have no cancel url
- dj-paddle version: 0.1.2
- Django version:.4.0.2
- Python version: 3.9.4
Description
We were quite suprised that out of 7 subscription only 2 have a cancel_url attached to it (the same 2 are the only ones with an update_url). Our cancel UX depends on this to be defined so I was wondering when the cancel_url should be created and how I could force a resync.
I'm having the exact same problem, so +1 on this issue. FYI @saschahofmann I found a workaround using the official API and request for subscription users which returns every subscription per user and you can filter out by user if needed later on.
👉 https://developer.paddle.com/api-reference/e33e0a714a05d-list-users
The reason appears to be that there are two events hitting the webhook simultaneously, for example: subscription_created (contains cancel_url field) subscription_payment_succeeded (contains no cancel_url field)
Depending on the order they are sent/processed, the cancel_url field is filled or remains empty in the database.
The solution seems to be to only enable the following webhook events in the Paddle console: Subscription Created Subscription Updated Subscription Cancelled
As far as I can tell at this point (I still only looked at it briefly), the other events are currently not really useful in combination with djpaddle because a lot of the fields they contain are not currently available in the Subscription model object.
When subscription_payment_succeeded come first, subscription_created come later => subscription_created payload will not be updated to Subscription instance, because event_time usually is same value for both alerts, low possibility it is different value but just a second, so it is not met condition below:
if subscription.event_time < data["event_time"]:
cls.objects.filter(pk=pk).update(**data)
So I'm working around by adding few seconds to the condition to allow the update happen.
if subscription.event_time < data["event_time"] + timedelta(seconds=5):
cls.objects.filter(pk=pk).update(**data)
I test manually by making around ten purchases in sandbox, I got expected result (cancel_url, update_url available).
subscription_payment_succeeded is required to update the next_bill_date field of the subscription when rebilling success. We should enable it.