#PSN-dupe-subs

1 messages · Page 1 of 1 (latest)

wet wraith
#

Hey, can you share an example object ID? Make the cus_xx you're seeing duplicates for

sharp gate
#

Yes

#

cus_MBXoOantD4eg6t

wet wraith
#

Checking!

sharp gate
#

ok

wet wraith
#
#

Looks like your integration is firing those unique requests. You should work to figure out why!

sharp gate
#

We manually refunded the other 2

#

I'm actually checking if active subs exists using this

#

subscription = payments.get_stripe_subscription(request.user)

#

before creating the new one

wet wraith
#

Yeah, but you asked why there's 'duplicate' subscriptions being created. The reality is they aren't duplicate, they're unique

wet wraith
sharp gate
#

oh

#

subscription = payments.get_stripe_subscription(request.user) if subscription["data"] != []: if subscription["data"][0]["status"] == "active": return Response({'status': False, 'message':"A Subscription already active"})

#

This is the complete checking part

#

@wet wraith

wet wraith
#

subscription["data"][0]["status"] == "active" is a bit naive, and potentially a race condition

#

How does your UI facilitate creating the subscriptions? Do you disable the button once pressed? Seems its being triggered multiple times in quick succession

sharp gate
#

Yes, I'm disabling the button

wet wraith
#

That is the best way, really. You need to figure out why your integration is firing multiple consecutive API requests to do the same single action