I am trying to integrate Stripe in my REST API using python. The client API call will provide the credit card info, address etc. I am using the below code create the PaymentMethod using the stripe test API Key.
async def my_payment_method(): payment_method = stripe.PaymentMethod.create( type="card", card={"number":"4242 4242 4242 4242","exp_month": 12,"exp_year": 2027,"cvc": 123 } )
The above code is throwing an exception,
Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using
I also tried to create the token using the below, but got the same error message as above
stripe.Token.create( card={"number": "4242424242424242","exp_month": "5","exp_year": "2028","cvc": "314", }, )
Thanks for helping to test the stripe API call.