0

this is my code:

def test(request):
paypalrestsdk.configure({
  "mode": "security-test-sandbox",
    "client_id": "XXXXXXX-XXXX-XXXX-XXXX",
    "client_secret": "XXXXXXX-XXXX-XXXX-XXXX"  })

payment = paypalrestsdk.Payment({
  "intent": "sale",
  "payer": {
    "payment_method": "credit_card",
    "funding_instruments": [{
      "credit_card": {
        "type": "visa",
        "number": "4417119669820331",
        "expire_month": "11",
        "expire_year": "2018",
        "cvv2": "874",
        "first_name": "Joe",
        "last_name": "Shopper" }}]},
  "transactions": [{
    "item_list": {
      "items": [{
        "name": "item",
        "sku": "item",
        "price": "1.00",
        "currency": "USD",
        "quantity": 1 }]},
    "amount": {
      "total": "1.00",
      "currency": "USD" },
    "description": "This is the payment transaction description." }]})

if payment.create():
  print("Payment created successfully")
else:
  print(payment.error)
return render(request, "test.html")

When performing the command payment.create () then it error : [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590) . I'm using Mac . please tell me why?

1 Answers1

4

I had the same problem and this is what I found and how I fixed:

The Python version provided by Apple is out of date in regards to openssl. You can test your version by going into terminal:

python
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 0.9.8zh 14 Jan 2016

Above is the bad version. One fix is to install a new version of python. The easiest way is probably to use home brew as described here.

Below is similar to what you should see with an upgraded version of python. Then the paypalrestsdk will work.

python
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2h  3 May 2016
JimJty
  • 141