Flutterwave 403 Ошибка клиента: Запрещено для url: https://api.flutterwave.com/v3/payments

Пожалуйста, мне нужна помощь в интеграции flutterwave в мой проект на django. Всякий раз, когда я нажимаю на кнопку оформления заказа на странице оплаты, я получаю приведенную выше ошибку.

Вот как выглядит мой вид флаттервейва:

Это представление используется для получения slug конкретного товара и цены при нажатии на кнопку оформления заказа def flutterwave(request,slug,price): mobile = Mobile.objects.get(user=request.user)

    try:
        food_product = food.get(slug=slug,food_price=price)
        #soup_product = soup.get(soup_item=product)
    except food.DoesNotExist:
        return JsonResponse({"error": "Food product does not exist"}, status=404, safe=False)

    
    url = "https://api.flutterwave.com/v3/payments"
    headers = {
        "Authorization": f"Bearer {FLUTTERWAVE_LIVE_SECRET_KEY}",
        "Content-Type": "application/json"
    }
    payload = {
        "tx_ref": tx_ref(),
        "amount": float(food_product.food_price),
        "currency": "NGN",
        "redirect_url": "http://127.0.0.1:8000/payments/verify_payment/",
        "meta": {
            "consumer_id": 23,
            "consumer_mac": "92a3-912ba-1192a"
        },
        "customer": {
            "email": request.user.email,
            "phonenumber": str(mobile.phone_no),
            "name": request.user.username
        },
        "customizations": {
            "title": "Pied Piper Payments",
            "logo": "http://www.piedpiper.com/app/themes/joystick-v27/images/logo.png"
        },
        "configurations": {
            "session_duration": 10,  # Session timeout in minutes (maxValue: 1440 minutes)
            "max_retry_attempt": 5   # Max retry attempts for failed transactions
        }
    }

    try:
        print("URL:", url)
        print("Headers:", headers)
        print("Payload:", payload)

        response = requests.post(url, headers=headers, json=payload)

        print("Response Type:", type(response))

        response.raise_for_status()  # Raise an error for bad status codes
 
        # Assuming the response is JSON, you can access it like this:
        json_response = response.json()
        return JsonResponse(json_response, safe=False)

    except requests.exceptions.RequestException as err:
        error_message = f"Error: {err}"
        return JsonResponse({"error": error_message}, status=500, safe=False)

Спасибо

Вернуться на верх