#rdnchhn668 - Code Question

1 messages · Page 1 of 1 (latest)

tranquil bramble
#

Hello! It's likely because you have two Customers with the same email. That causes the code in the for loop to run twice.

signal burrow
#

But when I run the code on desktop and not django I only get 1 result

tranquil bramble
#

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?

signal burrow
#

Ok well I guess that could be why.. I am running it for 1 product id then a second time for another product ID

tranquil bramble
#

Ah, that would do it.

signal burrow
#

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

tranquil bramble
#

Can you tell me why? We generally recommend you store some things, like Customer IDs, in your own database.

signal burrow
#

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

tranquil bramble
#

What are you building?

signal burrow
#

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

tranquil bramble
signal burrow
#

Yea I have and am using it but not for cancels. I want to store cancel reasons in my database

tranquil bramble
signal burrow
#

oh interesting did not know that. Was that added recently?

tranquil bramble
#

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.

signal burrow
#

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?

tranquil bramble
#

They choose the Subscription to cancel.

signal burrow
#

cool

#

maybe i will do that then

tranquil bramble
#

I recommend trying it out, it will save you a lot of work if it works for your use case!

signal burrow
#

where do i find portal settings?

#

nevermind found it

tranquil bramble
signal burrow
#

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?

tranquil bramble
#

If you're using the Dashboard to configure the portal you would use the setting in the Dashboard for this.

signal burrow
#

Yea I did that

#

Oh nevermind I didn't click save

#

I guess when someone cancels that way I have to use a webhook to change database values?

tranquil bramble
#

Yep, that would be my recommendation.

signal burrow
#

Where can I see the cancel reasons on stripe?

tranquil bramble
#

I thought they were on the Subscription, but I'm not seeing them there. Looking...

signal burrow
#

Ok

tranquil bramble
#

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.

signal burrow
#

oh wow ok

tranquil bramble
#

Yeah, I was surprised too!

signal burrow
#

For sure

#

where in the dashboard is it?

tranquil bramble
#

It should be visible on the Subscription.

signal burrow
#

Ah ok i see it

#

thank you for the help it gives me something to think about now