-
Notifications
You must be signed in to change notification settings - Fork 286
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
Cannot assign None: "Card.customer" does not allow null values. #231
Comments
As I follow the code path, it appears that what is happening is that you don't have the customer object in your database. I think In the meantime, I'm pretty sure you can avoid this by making sure you have customer records in your project.
from django.dispatch import receiver
from account.signals import user_signed_up
from pinax.eventlog.models import log
from pinax.stripe.actions import customers
@receiver(user_signed_up)
def handle_user_signed_up(sender, **kwargs):
log(
user=kwargs.get("user"),
action="USER_SIGNED_UP",
extra={}
)
customers.create(kwargs.get("user")) |
Yes, that is correct. Was I wrong in thinking the webhook does this automatically then? |
@ukch does what automatically? |
I'm seeing this issue too when running customer.create() and providing the card parameter. I think it's because there is a race condition in customer.create():
In some cases, it appears when the customer.source.created webhook arrives, the customer record in the database does not yet exist. This results in the none FK error. It'd be preferable not to have to create customer records for all users ahead of time. One option would be to change customers.create to use multiple API calls to Stripe rather than potentially creating a source and subscription in the one stripe.Customer.create call. |
I would assume that the order is correct, i.e. Related: #410 In case of the customer not existing already, it could also just get fetched an created then?! |
I got this through from the webhook:
This was the request body sent from Stripe:
The text was updated successfully, but these errors were encountered: