#rdnchhn668 - Code Question
1 messages · Page 1 of 1 (latest)
Hello! It's likely because you have two Customers with the same email. That causes the code in the for loop to run twice.
But when I run the code on desktop and not django I only get 1 result
Are you sure you're invoking the code in Django only once?
Looking closer it does look like the code wouldn't behave the way you're describing unless it was run twice.
Can you verify the list Customers call returns only a single Customer?
Ok well I guess that could be why.. I am running it for 1 product id then a second time for another product ID
Ah, that would do it.
It is very slow though if I do not store the customer ID in the database and do it the way you see in dpaste
I wanted to try and move away from storing the customer ID in the database
And look up everything in stripe
Can you tell me why? We generally recommend you store some things, like Customer IDs, in your own database.
because i probably have to restructure the database and make a stripe specific table
If I didn't have stripe stuff in the database it would save me some long planning of how to restructure things
What are you building?
e-learning site
right now I have a view in django that will change the form to cancel every subscription in 1 shot or they can choose what they want to cancel by clicking a radio button
that is why I am running the code twice to scan for recurring payments based on certain product ids
Have you looked into using the Customer Portal instead of building your own Subscription management interface? https://stripe.com/docs/invoicing/customer-portal
Yea I have and am using it but not for cancels. I want to store cancel reasons in my database
You can configure the Customer Portal to collect a cancellation reason: https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_cancel-cancellation_reason
oh interesting did not know that. Was that added recently?
We've had cancellation reasons in there for a little while now, but custom reasons (ones the customer can type in themselves) are fairly new.
ah that could be why I have not heard of it. Can the customer choose which product ID they want to cancel in the portal?
They choose the Subscription to cancel.
I recommend trying it out, it will save you a lot of work if it works for your use case!
You can configure the Customer Portal via the API and/or use the settings here in the Dashboard: https://dashboard.stripe.com/test/settings/billing/portal
Ok so I turned it on in the stripe dashboard
Here is my view in django for it
How do I add the features.subscription_cancel.cancellation_reason to it?
If you're using the Dashboard to configure the portal you would use the setting in the Dashboard for this.
Yea I did that
In billing.stripe.com/ I do not see anywhere for them to specify cancel reason
Oh nevermind I didn't click save
I guess when someone cancels that way I have to use a webhook to change database values?
Yep, that would be my recommendation.
Where can I see the cancel reasons on stripe?
I thought they were on the Subscription, but I'm not seeing them there. Looking...
Ok
Ah, okay, this isn't available in the API yet. It's planned and coming soon, but is only available in the Dashboard and Sigma today.
oh wow ok
Yeah, I was surprised too!
It should be visible on the Subscription.