#maks25-customer-python

1 messages · Page 1 of 1 (latest)

spiral bough
prisma blade
#

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..

spiral bough
#

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

prisma blade
#

Im passing the state and postal_code as strings..

spiral bough
#

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

prisma blade
#

** is an expand operator

spiral bough
#

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

prisma blade
#

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

spiral bough
#

Can you give me an example customer id so that I can have a look?

prisma blade
#

sure

#

cus_L21W63VOyBGtSE

#

thanks

spiral bough
#

it works right?

#

you send 12345 and in the response you have 12345

prisma blade
#

You're right

#

I was looking at the wrong thing. It's a front end issue not BE. It saves and queries properly.

Thank you