#usmanmukhtar - card delete python

1 messages · Page 1 of 1 (latest)

floral bridge
#

Hello, can you send me your python code that is getting that error?

twilit hill
#

`@action(detail=False, methods=['post'])
def delete(self, request):
try:
card_id = self.request.query_params.get('card_id')

        user = request.user

        source = stripe.Customer.delete_source(
            user.stripe_customer_id,
            card_id
        )
        card_list = stripe.Customer.list_sources(
            user.stripe_customer_id,
        )
        print(card_list)
        response = Constants.success_response(
            status.HTTP_200_OK,
            "Successfully retrieved cards",
            card_list.data
        )
        return response
        
    except Exception as e:
        response = Constants.error_response(
            status.HTTP_400_BAD_REQUEST,
            str(e)
        )
        return response

`

#

I'm such an idiot.. i figured it out I was sending form data but had request.query_params in my code

#

fixed it by changing it to request.data

thank you @floral bridge for help

floral bridge
#

Ah there we go. I was about to ask if you could double check that that card_id variable is populated and that explains why it wasn't