{"id":189,"library":"phonepe_sdk","title":"PhonePe Payment Gateway Python SDK","description":"Official PhonePe Payment Gateway Python SDK. NOT on PyPI — must install from PhonePe's private registry using a special pip command. TWO packages cause confusion: 'phonepe' on PyPI (1.0.1) is a community wrapper using old v1 API — NOT the official SDK. Official SDK is 'phonepe_sdk' from phonepe.mycloudrepo.io. Amount in paise (1 INR = 100 paise). Client must be initialized only ONCE — reinitializing raises PhonePeException. Mandatory status check polling after payment.","status":"active","version":"latest (from PhonePe registry)","language":"python","source_language":"en","source_url":"https://github.com/PhonePe/phonepe-pg-sdk-python","tags":["phonepe","payments","india","fintech","python","payment-gateway"],"install":[{"cmd":"pip install --index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python --extra-index-url https://pypi.org/simple phonepe_sdk","lang":"bash","label":"Python (official — from PhonePe registry, NOT PyPI)"}],"dependencies":[{"reason":"Required. Installed automatically.","package":"requests","optional":false}],"imports":[{"note":"Official SDK is NOT on PyPI. 'pip install phonepe' installs community wrapper using old v1 API. Official install requires --index-url flag pointing to PhonePe's registry.","wrong":"# Wrong: community package from PyPI — not official\nfrom phonepe import PhonePe\nphonepe = PhonePe('MERCHANT_ID', 'SALT', 'HOST', 'REDIRECT', 'WEBHOOK')\n\n# Wrong: pip install phonepe (wrong package)\n# Wrong: reinitializing client\nclient1 = StandardCheckoutClient(...)\nclient2 = StandardCheckoutClient(...)  # raises PhonePeException","symbol":"StandardCheckoutClient","correct":"from phonepe.sdk.pg.payments.v2.standard_checkout_client import StandardCheckoutClient\nfrom phonepe.sdk.pg.payments.v2.models.request.standard_checkout_pay_request import StandardCheckoutPayRequest\nfrom phonepe.sdk.pg.env import Env\nimport uuid\n\n# Initialize ONCE — reinitializing raises PhonePeException\nclient = StandardCheckoutClient(\n    client_id='<client_id>',\n    client_secret='<client_secret>',\n    client_version=1,\n    env=Env.SANDBOX  # or Env.PRODUCTION\n)\n\n# Create payment\norder_id = str(uuid.uuid4())\nrequest = StandardCheckoutPayRequest.build_request(\n    merchant_order_id=order_id,\n    amount=10000,  # 100 INR in paise\n    redirect_url='https://yourapp.com/callback'\n)\nresponse = client.pay(request)\nprint(response.redirect_url)  # redirect user here"}],"quickstart":{"code":"# Install from PhonePe registry (NOT PyPI):\n# pip install --index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python --extra-index-url https://pypi.org/simple phonepe_sdk\n\nfrom phonepe.sdk.pg.payments.v2.standard_checkout_client import StandardCheckoutClient\nfrom phonepe.sdk.pg.payments.v2.models.request.standard_checkout_pay_request import StandardCheckoutPayRequest\nfrom phonepe.sdk.pg.env import Env\nimport uuid\n\n# Initialize once at app startup\nclient = StandardCheckoutClient(\n    client_id='<client_id>',       # from PhonePe dashboard\n    client_secret='<client_secret>',\n    client_version=1,\n    env=Env.SANDBOX\n)\n\n# Create payment\norder_id = str(uuid.uuid4())\nrequest = StandardCheckoutPayRequest.build_request(\n    merchant_order_id=order_id,\n    amount=50000,  # 500 INR in paise\n    redirect_url=f'https://yourapp.com/callback?order_id={order_id}'\n)\nresponse = client.pay(request)\n\n# Redirect user to response.redirect_url\nprint('Redirect to:', response.redirect_url)\n\n# After redirect, check status (mandatory)\nstatus = client.get_order_status(merchant_order_id=order_id)\nprint('Payment state:', status.state)  # COMPLETED, FAILED, PENDING","lang":"python","description":"PhonePe Python SDK — payment creation and status check."},"warnings":[{"fix":"pip install --index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python --extra-index-url https://pypi.org/simple phonepe_sdk","message":"Official PhonePe SDK is NOT on PyPI. 'pip install phonepe_sdk' alone fails. Must use --index-url pointing to PhonePe's private registry.","severity":"breaking","affected_versions":"all"},{"fix":"Use official phonepe_sdk from PhonePe's registry, not 'pip install phonepe' from PyPI.","message":"'phonepe' on PyPI (1.0.1) is a community package using old PhonePe v1 API — NOT the official SDK. Using it risks API deprecation and lacks official support.","severity":"breaking","affected_versions":"all"},{"fix":"Initialize at app startup as a singleton. Use dependency injection or module-level variable.","message":"StandardCheckoutClient must be initialized ONLY ONCE per application. Reinitializing raises PhonePeException.","severity":"breaking","affected_versions":"all"},{"fix":"amount_in_paise = amount_in_inr * 100","message":"Amount is in paise (1 INR = 100 paise) — same as Razorpay. 500 INR = 50000 paise. Passing rupees directly will undercharge.","severity":"breaking","affected_versions":"all"},{"fix":"Always call client.get_order_status(merchant_order_id=order_id) after redirect to confirm payment state.","message":"Status check after payment is MANDATORY. PhonePe docs require polling get_order_status() after redirect — do not rely on redirect callback alone.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Env.SANDBOX with sandbox credentials for testing. Switch to Env.PRODUCTION with live credentials for deployment.","message":"SANDBOX uses test credentials from PhonePe merchant dashboard. Sandbox and Production have different client_id/secret pairs.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure 'setuptools' is installed in your environment (e.g., by running `pip install setuptools`). In Docker environments based on minimal images like Alpine, you might need to explicitly add this to your Dockerfile.","message":"ModuleNotFoundError: No module named 'pkg_resources' occurs when the 'setuptools' package is not installed. This module is a dependency of 'apscheduler', which the PhonePe SDK utilizes.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"search_vec":"'1':57 '1.0.1':34 '100':59 'amount':54 'api':42 'caus':29 'check':72 'client':61 'command':26 'communiti':37 'confus':30 'fintech':79 'gateway':3,9,83 'india':78 'initi':64 'inr':58 'instal':16 'mandatori':70 'must':15,62 'offici':6,45,47 'old':40 'packag':28 'pais':56,60 'payment':2,8,75,77,82 'payment-gateway':81 'phonep':1,7,18,31,50,76 'phonepe.mycloudrepo.io':53 'phonepeexcept':69 'pip':25 'poll':73 'privat':20 'pypi':14,33 'python':4,10,80 'rais':68 'registri':21 'reiniti':67 'sdk':5,11,46,48,51 'special':24 'status':71 'two':27 'use':22,39 'v1':41 'wrapper':38","created_at":"2026-03-25T03:09:41.531692+00:00","updated_at":"2026-04-16T18:00:00.912420+00:00","problems":{"verify_error":"error: unexpected argument '--index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python --extra-index-url https://pypi.org/simple phonepe_sdk' found\n\n  tip: to pass '--index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python --extra-index-url https:"},"ecosystem":"pypi","meta_description":null,"install_score":50,"quickstart_score":30,"quickstart_tag":"draft","pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://www.phonepe.com","github":null,"docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["payments"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-27","last_verified":"2026-06-27","next_check":"2026-07-04","install_tag":"draft"}}