{"id":182,"library":"cashfree_pg","title":"Cashfree Payment Gateway Python SDK","description":"Official Cashfree Payment Gateway Python SDK. Current version: 5.0.6 (Mar 2026). THREE packages on PyPI causing confusion: 'cashfree-sdk' (0.1.3 — beta, NOT recommended for production by Cashfree), 'cashfree_pg' (5.0.6 — correct current PG SDK), 'cashfree' (1.0.1 — unrelated package). Use cashfree_pg. API version string must be passed to every API call. Supports SANDBOX and PRODUCTION environments. Amount in rupees (float) — unlike Razorpay which uses paise.","status":"active","version":"5.0.6","language":"python","source_language":"en","source_url":"https://github.com/cashfree/cashfree-pg-sdk-python","tags":["cashfree","payments","india","fintech","python","payment-gateway"],"install":[{"cmd":"pip install cashfree_pg","lang":"bash","label":"Python (correct PG SDK — use this)"}],"dependencies":[{"reason":"Required. Installed automatically.","package":"requests","optional":false}],"imports":[{"note":"Use 'cashfree_pg' not 'cashfree-sdk' or 'cashfree'. cashfree-sdk explicitly states it is NOT recommended for production. Amount is in rupees (float), not paise.","wrong":"# Wrong package — not recommended for production\nfrom cashfree_sdk.pg import PG\n\n# Wrong package — unrelated\nimport cashfree","symbol":"Cashfree PG client + order creation","correct":"from cashfree_pg.models.create_order_request import CreateOrderRequest\nfrom cashfree_pg.api_client import Cashfree\nfrom cashfree_pg.models.customer_details import CustomerDetails\nfrom cashfree_pg.models.order_meta import OrderMeta\n\ncashfree = Cashfree(\n    XEnvironment=Cashfree.SANDBOX,  # or Cashfree.PRODUCTION\n    XClientId='<x-client-id>',\n    XClientSecret='<x-client-secret>'\n)\n\nx_api_version = '2023-08-01'  # required for every call\n\ncustomer = CustomerDetails(\n    customer_id='cust_001',\n    customer_phone='9999999999'\n)\norder_meta = OrderMeta(\n    return_url='https://yourapp.com/payment/callback?order_id={order_id}'\n)\ncreate_request = CreateOrderRequest(\n    order_amount=500.00,  # in rupees (not paise)\n    order_currency='INR',\n    customer_details=customer,\n    order_meta=order_meta\n)\n\nresponse = cashfree.PGCreateOrder(x_api_version, create_request, None, None)\nprint(response.data.order_id)"}],"quickstart":{"code":"# pip install cashfree_pg\nfrom cashfree_pg.api_client import Cashfree\nfrom cashfree_pg.models.create_order_request import CreateOrderRequest\nfrom cashfree_pg.models.customer_details import CustomerDetails\nfrom cashfree_pg.models.order_meta import OrderMeta\n\n# Initialize — get keys from dashboard.cashfree.com\ncashfree = Cashfree(\n    XEnvironment=Cashfree.SANDBOX,\n    XClientId='TEST_APP_ID',\n    XClientSecret='TEST_SECRET_KEY'\n)\n\nx_api_version = '2023-08-01'  # pass to every API call\n\n# Create order\ncustomer = CustomerDetails(customer_id='cust_001', customer_phone='9999999999')\nmeta = OrderMeta(return_url='https://yourapp.com/callback?order_id={order_id}')\n\nrequest = CreateOrderRequest(\n    order_amount=499.00,   # rupees, not paise\n    order_currency='INR',\n    customer_details=customer,\n    order_meta=meta\n)\n\ntry:\n    response = cashfree.PGCreateOrder(x_api_version, request, None, None)\n    print('Order ID:', response.data.order_id)\n    print('Payment URL:', response.data.payment_link)\nexcept Exception as e:\n    print('Error:', e)\n\n# Fetch order status\ntry:\n    order = cashfree.PGFetchOrder(x_api_version, response.data.order_id, None)\n    print('Status:', order.data.order_status)\nexcept Exception as e:\n    print('Error:', e)","lang":"python","description":"Cashfree PG Python SDK — create and fetch order."},"warnings":[{"fix":"pip install cashfree_pg — this is the official current SDK.","message":"Three packages on PyPI: cashfree-sdk (beta/not for production), cashfree_pg (correct SDK), cashfree (unrelated). LLMs and old tutorials reference cashfree-sdk which Cashfree explicitly says is not for production.","severity":"breaking","affected_versions":"all"},{"fix":"x_api_version = '2023-08-01'; cashfree.PGCreateOrder(x_api_version, request, None, None)","message":"x_api_version string must be passed to every API call. Omitting it raises TypeError. Unlike Razorpay which doesn't require API version per call.","severity":"breaking","affected_versions":"all"},{"fix":"order_amount=500.00 means ₹500. No multiplication needed.","message":"Amount is in RUPEES (float) — not paise. Unlike Razorpay which uses paise. 500 means ₹500. This is the opposite of Razorpay's convention.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Cashfree.SANDBOX for testing, Cashfree.PRODUCTION for live. Keys are different for each environment.","message":"SANDBOX environment uses TEST keys from Cashfree dashboard. Test client IDs start with 'TEST_'. Production keys are different — switch XEnvironment=Cashfree.PRODUCTION with live keys.","severity":"gotcha","affected_versions":"all"},{"fix":"return_url='https://yourapp.com/callback?order_id={order_id}'","message":"return_url in OrderMeta must include {order_id} placeholder — Cashfree replaces it with actual order ID. Missing placeholder means you can't identify which order was paid.","severity":"gotcha","affected_versions":"all"},{"fix":"Whitelist server IP in Cashfree dashboard → Settings → IP Whitelist.","message":"IP whitelisting required for production. Cashfree blocks API calls from non-whitelisted IPs in production. Add your server IP in Cashfree dashboard under Security settings.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T09:47:44.264Z","next_check":"2026-06-25T00:00:00.000Z","problems":[{"fix":"Ensure the correct package is installed using `pip install cashfree_pg`.","cause":"The `cashfree_pg` library is not installed in the current Python environment, or an attempt is made to import it while an older/incorrect package (like `cashfree-sdk` or `cashfree`) was installed.","error":"ModuleNotFoundError: No module named 'cashfree_pg'"},{"fix":"After ensuring `cashfree_pg` is installed, use `from cashfree_pg.api_client import Cashfree`.","cause":"The developer is attempting to import from a deprecated or incorrect Cashfree SDK package (`cashfree-sdk` or `cashfree`) instead of the official `cashfree_pg` library.","error":"from cashfree_sdk import Cashfree"},{"fix":"Verify your `X-Client-Id` and `X-Client-Secret` from your Cashfree Merchant Dashboard and ensure `XEnvironment` (e.g., `Cashfree.SANDBOX` or `Cashfree.PRODUCTION`) is set correctly during SDK initialization.","cause":"The provided API keys (X-Client-Id, X-Client-Secret) are incorrect, expired, or do not match the environment (SANDBOX/PRODUCTION) being used.","error":"authentication_error, Invalid or missing authentication credentials"},{"fix":"Update the `x_api_version` parameter in your API calls to a currently supported version, such as \"2023-08-01\" or the latest version specified in the Cashfree documentation.","cause":"The `x_api_version` string passed to the API call is not one of the currently supported versions.","error":"\"message\":\"version value should be 2021-05-21 or 2022-01-01 or 2022-09-01 or 2023-08-01\",\"code\":\"request_failed\",\"type\":\"invalid_request_error\""},{"fix":"Double-check that your `X-Client-Id` and `X-Client-Secret` used for signature generation are correct and that all order details (e.g., `order_id`, `order_amount`, `order_currency`) passed to the API exactly match those used to create any associated tokens or signatures.","cause":"This error typically occurs when the signature generated on your backend (using your secret key and order details) does not match the signature Cashfree calculates, often due to incorrect credentials or a mismatch in transaction parameters like `orderId` or `orderAmount`.","error":"SignatureMismatch error"}],"ecosystem":"pypi","meta_description":null,"install_score":95,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.82,"mem_mb":26.2,"disk_size":"35.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.96,"mem_mb":26.2,"disk_size":"35M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.58,"mem_mb":26.9,"disk_size":"39.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3,"mem_mb":26.9,"disk_size":"39M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.98,"mem_mb":26.6,"disk_size":"30.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.92,"mem_mb":26.6,"disk_size":"31M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.48,"mem_mb":25.9,"disk_size":"30.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.5,"mem_mb":25.9,"disk_size":"30M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.57,"mem_mb":26.5,"disk_size":"34.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.33,"mem_mb":26.5,"disk_size":"34M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}