Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions have no cancel url #39

Open
saschahofmann opened this issue May 31, 2022 · 3 comments
Open

Subscriptions have no cancel url #39

saschahofmann opened this issue May 31, 2022 · 3 comments

Comments

@saschahofmann
Copy link

  • 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.

@vectorsize
Copy link

vectorsize commented Sep 2, 2022

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

@DonvdH
Copy link

DonvdH commented Sep 8, 2022

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.

@nowendwar
Copy link

nowendwar commented Oct 18, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants