#maks25-customer-python
1 messages · Page 1 of 1 (latest)
Hello! Can you share your code? Also are you catching errors https://stripe.com/docs/api/errors properly?
Sure
the serializers
class StripeCustomerAddressSerializer(serializers.Serializer):
country = serializers.CharField(max_length=2)
city = serializers.CharField(max_length=200, allow_blank=True, allow_null=True, required=False)
line1 = serializers.CharField(max_length=200, allow_blank=True, allow_null=True, required=False)
line2 = serializers.CharField(max_length=200, allow_blank=True, allow_null=True, required=False)
postal_code = serializers.CharField(max_length=20, allow_blank=True, allow_null=True, required=False)
state = serializers.CharField(max_length=20, allow_blank=True, allow_null=True, required=False)
class StripeCustomerSerializer(serializers.Serializer):
name = serializers.CharField(max_length=100)
email = serializers.EmailField()
address = StripeCustomerAddressSerializer()
the actual request
serializer = StripeCustomerSerializer(data=self.request.data)
serializer.is_valid(raise_exception=True)
stripe.Customer.modify(
stripe_link.stripe_cus_id,
**serializer.validated_data
)
Sorry I am not seeing a paste as code option here in discord..
you just wrap it in three ` before/after
I'd recommend temporarily moving away from your serializers for a bit and trying the code with hardcoded values, confirm that works, and then compare to what your serializers do
Im passing the state and postal_code as strings..
you're not though
you're passing **serialize.validated_data
I don't really grasp what your code is trying to do but I'm assuming you either don't send anything to the API, something errors because you don't catch errors
** is an expand operator
Sure, but I'm trying to help you debug this
Step 1: try the call without any of this magic
confirm if it works or not, then we can figure out step 2
I have simplified the request:
stripe.Customer.modify(
stripe_link.stripe_cus_id,
**{'name': 'John Doe', 'email': 'john@doe.com',
'address': {'country': 'US', 'city': 'Phoenix', 'line1': 'something something', 'line2': 'something something 2',
'postal_code': '12345', 'state': 'AZ'}}
)
everything saves correctly except postal_code and state
Or even more simplified:
stripe.Customer.modify(
stripe_link.stripe_cus_id,
name='John Doe',
email='john@doe.com',
address={'country': 'US', 'city': 'Phoenix', 'line1': 'something something',
'line2': 'something something 2',
'postal_code': '12345', 'state': 'AZ'}
)
The postal_code and the state is not updating.
everything else works fine
Can you give me an example customer id so that I can have a look?
I don't really get it. Look at https://dashboard.stripe.com/test/logs/req_J1yZrTzcRzny7e
it works right?
you send 12345 and in the response you have 12345