4
votes

I am implementing Stripe payment gateway in sandbox mode. I have embedded checkout process and also created token which is used by server to call API to create charges.

API version used is: stripe.api_version = '2017-06-05'

charge = stripe.Charge.create(
   amount=1000,
   currency="usd",
   description="Example charge",
   source=token,
)

When I call this charge create api, I receive the following error:

b'{\n "error": {\n "type": "invalid_request_error",\n
"message": "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls."\n }\n}\n'

The stripe API used to create charges in local machine is:

POST: https://api.stripe.com/v1/charges

How can I make it work on my local machine?

But when I deployed it to AWS it is working there.

1

1 Answers

4
votes

Your local Python interpreter is linked against an older version of OpenSSL that does not support TLS 1.2. You can check this with:

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"

You need OpenSSL 1.0.1 or more recent to use TLS 1.2.

If you're using OS X, the simplest way to fix this is to the use Homebrew package manager:

$ brew update && brew upgrade && brew install openssl && brew install python

Replace python with python3 at the end of the command line above if you're using Python 3.