Оплата кредитной картой PayPal не выполняется - PullRequest
1 голос
/ 24 февраля 2020

Я использую учетную запись PayPal Sandbox. Python SDK PayPal- Python -SDK

Я успешно создал платеж, используя хранилища кредитных карт (кредитные / дебетовые карты), но не смог выполнить платеж, получив ошибку.

card = Card.objects.get(id = request.data['cardId'])
paypalrestsdk.configure({
            "mode": settings.PAYPAL_MODE, # sandbox or live
            "client_id": settings.PAYPAL_CLIENT_ID,
            "client_secret": settings.PAYPAL_CLIENT_SECRET
})

payment = paypalrestsdk.Payment({
    "intent": "sale",
    "payer": {
        "payment_method": "credit_card",
        "funding_instruments": [{
            "credit_card_token": {
                "credit_card_id": card.token,
            }
        }]
    },
    "transactions": [{
        "amount": {
            "total": float(request.data['amount']),
            "currency": "USD"
        },
        "description": "Payment by vaulted credit card."
    }]
})
if payment.create():
    print(payment.id)
    print("Payment created successfully")
    # ID of the payment. This ID is provided when creating payment.
    payment = paypalrestsdk.Payment.find(payment.id)
    # PayerID is required to approve the payment(card token).
    if payment.execute({"payer_id": card.token}):  # return True or False (card.token : added card token - CARD-7K172274P2897384FLZJ3VCC) 
        print("Payment[%s] execute successfully" % (payment.id))
    else:
        print(payment.error)
else:
    print(payment.error)

полученная ошибка:

  Failed. Response status: 404. Response message: Not Found. Error message: {\"name\":\"INVALID_RESOURCE_ID\",\"message\":\"Requested resource ID was not found.\",\"information_link\":\"https://developer.paypal.com/docs/api/payments/#errors\",\"debug_id\":\"be43810866322\"}
...