원클릭으로
phonepe-pg-skill
Assist in integrating with PhonePe PG APIs for one-time payments, payment links, and refunds
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Assist in integrating with PhonePe PG APIs for one-time payments, payment links, and refunds
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | phonepe-pg-skill |
| description | Assist in integrating with PhonePe PG APIs for one-time payments, payment links, and refunds |
| metadata | {"author":"PhonePe","version":"1.4.0"} |
Reference these guidelines when:
AUTHORIZATION_FAILED, INVALID_TRANSACTION_ID, or token expiry errorsNot all PhonePe PG integration flows are available to all merchants by default. Each restricted flow is an individually enabled permission — enabling one does not enable another.
| Flow | Default Available | Permission(s) Required |
|---|---|---|
| Standard Checkout (one-time payment) | ✅ Yes | — |
| Custom Checkout (one-time payment) | ❌ No | Custom Checkout permission |
| Standard Checkout AutoPay | ❌ No | AutoPay permission |
| Custom Checkout AutoPay | ❌ No | Custom Checkout permission + AutoPay permission (both individually) |
| Payment Links | ❌ No | Payment Links permission |
ℹ️ Each permission is granted independently by the PhonePe team. For example, having AutoPay enabled does not automatically enable Custom Checkout, and vice versa.
AI must follow this rule for any restricted flow:
Before generating any integration code or configuration for Custom Checkout, AutoPay (Standard or Custom), or Payment Links — ask the merchant to confirm that the required permission(s) have been enabled for their account by PhonePe. If they are unsure, direct them to contact their PhonePe account manager or onboarding team. Do not proceed with integration steps until confirmation is received.
ID: SKILL_AUTH_GENERATE
Description: Every PhonePe PG API request requires an O-Bearer access token obtained from /v1/oauth/token. Tokens should be cached and reused until near expiry to avoid unnecessary round-trips.
⚠️ Environment Note: The OAuth API path differs between Sandbox and Production — a simple host swap is not sufficient. See the endpoint table below.
current_time < expires_at - 60 seconds, use it.access_token and expires_at from the response.access_token to the calling skill via Authorization: O-Bearer <access_token>.| Environment | Method | URL |
|---|---|---|
| Sandbox | POST | https://api-preprod.phonepe.com/apis/pg-sandbox/v1/oauth/token |
| Production | POST | https://api.phonepe.com/apis/identity-manager/v1/oauth/token |
Headers:
Content-Type: application/x-www-form-urlencoded
Request Fields:
| Field | Type | Required | Description |
|---|---|---|---|
client_id | String | YES | Merchant Client ID provided by PhonePe |
client_secret | String | YES | Merchant Client Secret provided by PhonePe |
client_version | Integer | YES | Client version number provided by PhonePe |
grant_type | String | YES | Must be client_credentials |
Sample Request:
curl --location 'https://api-preprod.phonepe.com/apis/pg-sandbox/v1/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=CLIENT_ID' \
--data-urlencode 'client_version=CLIENT_VERSION' \
--data-urlencode 'client_secret=CLIENT_SECRET' \
--data-urlencode 'grant_type=client_credentials'
Response Fields:
| Field | Type | Description |
|---|---|---|
access_token | String | Bearer token for API authorization |
token_type | String | Always O-Bearer |
expires_at | Long | Token expiry (Unix epoch seconds) |
issued_at | Long | Token issue time (Unix epoch seconds) |
Sample Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MjA2MzUzMjE5OTYsIm1lcmNoYW50SWQiOiJWUlVBVCJ9.4YjYHI6Gy6gzOisD_628wfbaI46dMSc5T_0gZ2-SAJo",
"encrypted_access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MjA2MzUzMjE5OTYsIm1lcmNoYW50SWQiOiJWUlVBVCJ9.4YjYHI6Gy6gzOisD_628wfbaI46dMSc5T_0gZ2-SAJo",
"issued_at": 1706073005,
"expires_at": 1706697605,
"session_expires_at": 1706697605,
"token_type": "O-Bearer"
}
| HTTP Code | Cause | Action |
|---|---|---|
| 400 | Missing or malformed credentials | Verify all 4 request fields are present |
| 401 | Invalid client_id or client_secret | Check credentials with PhonePe PG team |
| 500 | Server error | Retry after a short delay |
Content-Type: application/x-www-form-urlencodedclient_id, client_secret, client_version, grant_type=client_credentialsaccess_token and expires_at; refresh proactively 60 seconds before expiryAuthorization: O-Bearer <access_token> in all downstream API callsID: SKILL_PAYMENT_REFUND
Description: Processes a full or partial refund for a successful PhonePe transaction.
Prerequisite: The original order must be in COMPLETED state. Call SKILL_AUTH_GENERATE to obtain a valid token.
SKILL_AUTH_GENERATE to obtain access_token.COMPLETED before proceeding.Authorization: O-Bearer <access_token>.refundId and state, or surface error details.| Environment | Method | URL |
|---|---|---|
| Sandbox | POST | https://api-preprod.phonepe.com/apis/pg-sandbox/payments/v2/refund |
| Production | POST | https://api.phonepe.com/apis/pg/payments/v2/refund |
Headers:
Authorization: O-Bearer <access_token>
Content-Type: application/json
Request Fields:
| Field | Type | Required | Description | Validation |
|---|---|---|---|---|
merchantRefundId | String | YES | Unique identifier for this refund | Max 63 chars; alphanumeric, _, - only |
originalMerchantOrderId | String | YES | The merchantOrderId of the order being refunded | Must correspond to a COMPLETED order |
amount | Long | YES | Refund amount in paisa | Must be ≤ original order amount |
Sample Request:
{
"merchantRefundId": "REFUND-12345",
"originalMerchantOrderId": "ORDER-12345",
"amount": 1234
}
Sample Response (Refund Accepted):
{
"refundId": "OMRxxxxx",
"amount": 1234,
"state": "PENDING"
}
Refund States:
| State | Meaning | Recommended Action |
|---|---|---|
PENDING | Refund accepted and queued for processing | Track refundId; poll or await webhook for completion |
COMPLETED | Refund successfully credited to the customer | Notify the customer and update your records |
FAILED | Refund could not be processed | Contact PhonePe PG support with the refundId |
| HTTP Code | Error Code | Cause | Action |
|---|---|---|---|
| 200/201 | — | Refund accepted | Return refundId and state |
| 400 | BAD_REQUEST | Invalid payload or amount exceeds original | Validate all fields; check amount |
| 401 | AUTHORIZATION_FAILED | Expired or invalid token | Call SKILL_AUTH_GENERATE to refresh, then retry once |
| 402 | — | Refund not eligible | Review refund eligibility with PhonePe |
| 403 | FORBIDDEN | Insufficient permissions | Verify merchant credentials |
| 500 | INTERNAL_SERVER_ERROR | Server error | Retry after delay; escalate to support if persistent |
SKILL_AUTH_GENERATE first to obtain access_tokenAuthorization: O-Bearer <access_token> header (not Bearer)merchantRefundId is unique — do not reuse refund IDsamount does not exceed the original order amountrefundId for trackingstate will be PENDING; completion is asynchronousFor Standard Checkout (PhonePe-hosted payment page + JS SDK), refer to: Standard Checkout Integration
Skills included:
For recurring subscription mandate setup using PhonePe's hosted page and JS SDK, refer to: Standard Checkout AutoPay
Skills included:
SUBSCRIPTION_CHECKOUT_SETUP); launch hosted page via JS SDKSUBSCRIPTION_CHECKOUT_REDEMPTION)For Custom Checkout (merchant-controlled payment UI), refer to: Custom Checkout Integration
Skills included:
For recurring subscription mandate setup where the merchant controls the payment UI (UPI_INTENT or UPI_COLLECT), refer to: Custom Checkout AutoPay
Skills included:
SUBSCRIPTION_SETUP)For collecting one-time payments by generating a shareable link (no checkout UI required), refer to: Payment Links
Skills included: