This repository contains Agent Skills for integrating with PhonePe Payment Gateway APIs. These skills enable GitHub Copilot CLI, Copilot coding agent, and VS Code to assist you in implementing PhonePe PG integration with proper authentication, payment flows, and error handling.
- About These Skills
- Prerequisites
- Setup Instructions
- Available Skills
- Usage Examples
- Environment Configuration
- Troubleshooting
This skill collection provides AI-powered assistance for:
- β Authentication - OAuth token generation and management for PhonePe PG APIs
- β Standard Checkout - One-time payment integration
- β Refunds - Processing full or partial refunds
- π AutoPay - Recurring payment setup (coming soon)
These skills follow PhonePe's official API specifications and handle common integration scenarios, error handling, and best practices.
Before using these skills, ensure you have:
-
PhonePe Payment Gateway Account
- Merchant ID
- Client ID and Client Secret
- API credentials (sandbox and/or production)
-
GitHub Copilot CLI (or one of the supported tools)
- Install:
brew install copilot-clior other installation methods - Active Copilot subscription
- Install:
-
Development Environment
- Bash shell (for setup script)
- Programming language of your choice (Node.js, Python, Java, etc.)
- HTTPS-enabled callback URL for payment redirects
Install directly with a single command:
# Using wget
wget -qO- https://raw.githubusercontent.com/PhonePe/phonepe-pg-skills/main/setup.sh | bash
# Or using curl
curl -fsSL https://raw.githubusercontent.com/PhonePe/phonepe-pg-skills/main/setup.sh | bashThe script will:
- Check prerequisites (Git, GitHub Copilot CLI)
- Clone the repository automatically
- Guide you through setup for new or existing projects
- Create .env.template with configuration
- Update .gitignore for security
If you prefer to clone first:
git clone https://github.com/PhonePe/phonepe-pg-skills.git
cd phonepe-pg-skills
./setup.shClick to expand manual setup instructions
If you're starting a new project:
# Clone this repository
git clone https://github.com/PhonePe/phonepe-pg-skills.git
cd phonepe_pg_skills
# Start GitHub Copilot CLI in this directory
copilotIf adding to an existing project:
# Copy the skills directory to your project
cp -r .github/skills /path/to/your/project/.github/
# Navigate to your project
cd /path/to/your/project
# Start GitHub Copilot CLI
copilotStart Copilot CLI in your project directory:
copilotThen prompt Copilot:
Help me integrate PhonePe payment gateway. Create a payment order for βΉ100 with order ID "ORDER123" and redirect URL "https://mysite.com/callback"
Copilot will:
- Fetch authentication token using your credentials
- Build the correct API payload
- Generate code to make the API call
- Parse and return the payment URL
Create a Node.js function to initiate a PhonePe payment with the following:
- Order ID: Generate unique ID
- Amount: βΉ500
- Enable only UPI and credit cards
- Add metadata with user ID
- Handle success and error responses
Help me refund order "ORDER123" for βΉ100. Create a function that handles the refund API call with proper error handling.
I'm getting "AUTHORIZATION_FAILED" error when calling PhonePe checkout API. Help me debug this.
Copilot will:
- Check your authentication flow
- Verify token generation logic
- Suggest fixes based on error codes
Sandbox (Testing):
PHONEPE_ENV=sandbox
# Uses: https://api-preprod.phonepe.com/apis/pg-sandbox/Production:
PHONEPE_ENV=production
# Uses: https://api.phonepe.com/apis/pg/Create config/phonepe.js (Node.js example):
module.exports = {
environment: process.env.PHONEPE_ENV || 'sandbox',
clientId: process.env.PHONEPE_CLIENT_ID,
clientSecret: process.env.PHONEPE_CLIENT_SECRET,
clientVersion: process.env.PHONEPE_CLIENT_VERSION,
merchantId: process.env.PHONEPE_MERCHANT_ID,
redirectUrl: process.env.PHONEPE_REDIRECT_URL,
};Problem: /skills list returns empty
Solutions:
- Check file structure:
.github/skills/phonepe-pg-skill/SKILL.mdmust exist - Verify SKILL.md frontmatter has lowercase
namefield - Run
/skills reload - Restart Copilot CLI
Problem: Getting AUTHORIZATION_FAILED or 401 errors
Solutions:
- Verify credentials are correct
- Check if token is expired (tokens last ~7 days)
- Ensure
O-Bearerprefix in Authorization header - Confirm environment (sandbox vs production) matches credentials
Problem: Error INVALID_TRANSACTION_ID or 417 status
Solutions:
- Ensure
merchantOrderIdis unique per transaction - Check that Order ID only contains alphanumeric,
_, and- - Maximum length is 63 characters
Contributions to PG Java SDK are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows the project's coding standards and includes appropriate tests.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright 2026 PhonePe Private Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.