wontonee/phonepe

PhonePe Payment Gateway for Bagisto - Professional integration with OAuth 2.0 authentication

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/wontonee/phonepe

dev-main 2025-10-06 06:53 UTC

This package is not auto-updated.

Last update: 2025-10-06 19:40:18 UTC


README

Professional PhonePe payment gateway integration for Bagisto e-commerce platform with OAuth 2.0 authentication.

๐Ÿš€ Features

Payment Processing

  • OAuth 2.0 Authentication: Secure token-based API authentication
  • Multiple Payment Methods: UPI, Cards, Net Banking, and Wallets
  • Environment Support: Sandbox for testing, Production for live transactions
  • Automatic Amount Conversion: Handles paisa conversion automatically
  • Order Management: Seamless integration with Bagisto order system

Security & Reliability

  • Secure Token Generation: OAuth 2.0 access token with automatic expiry handling
  • Payment Verification: Server-side payment status verification
  • Session Management: Secure session handling for payment data
  • Comprehensive Logging: Detailed logs for debugging and monitoring

Admin Features

  • Easy Configuration: Simple admin panel setup
  • Environment Toggle: Switch between Sandbox and Production
  • Customizable: Configure order expiry time
  • Payment Method Icon: Upload custom payment method icon

๐Ÿ“‹ Requirements

  • Bagisto 2.x
  • PHP 8.1 or higher
  • PhonePe Business Account
  • Client ID and Client Secret from PhonePe Dashboard

๐Ÿ“ฆ Installation

Step 1: Install via Composer

composer require wontonee/Phonepe

Step 2: Publish Assets

php artisan vendor:publish --tag=Phonepe-assets

Step 3: Clear Cache

php artisan config:cache
php artisan route:cache
php artisan optimize:clear

โš™๏ธ Configuration

1. Get PhonePe Credentials

  1. Login to PhonePe Business Dashboard
  2. Navigate to Developer Settings
  3. Copy your Client ID and Client Secret

2. Configure in Bagisto Admin

  1. Go to Admin Panel โ†’ Configuration โ†’ Sales โ†’ Payment Methods
  2. Find PhonePe in the payment methods list
  3. Configure the following fields:
Field Description Required
Title Display name for payment method Yes
Description Description shown to customers No
Payment Method Icon Upload custom icon (100x50px recommended) No
Environment Select Sandbox or Production Yes
Client ID Your PhonePe Client ID Yes
Client Secret Your PhonePe Client Secret Yes
Client Version API Client Version (Default: 1) Yes
Checkout Type Select Standard or Express (Default: Standard) Yes
Status Enable/Disable payment method Yes
  1. Click Save Configuration

๐Ÿ”ง How It Works

Payment Flow

  1. Customer Checkout: Customer selects PhonePe and places order
  2. OAuth Authentication: System generates OAuth access token
  3. Payment Creation: Payment order created via PhonePe API
  4. Redirect to PhonePe: Customer redirected to PhonePe payment page
  5. Payment Processing: Customer completes payment on PhonePe
  6. Callback: PhonePe redirects back with payment status
  7. Verification: System verifies payment status with PhonePe
  8. Order Creation: Order created if payment successful

API Endpoints

Sandbox:

  • Auth: https://api-preprod.phonepe.com/apis/pg-sandbox/v1/oauth/token
  • Payment: https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/pay

Production:

  • Auth: https://api.phonepe.com/apis/identity-manager/v1/oauth/token
  • Payment: https://api.phonepe.com/apis/pg/checkout/v2/pay

๐Ÿงช Testing

Sandbox Testing

  1. Set Environment to Sandbox
  2. Use your PhonePe sandbox credentials
  3. Test with PhonePe test payment methods

Test Credentials

Contact PhonePe support for sandbox test credentials.

๐Ÿ“ Important Notes

Amount Handling

  • PhonePe requires amounts in paisa (โ‚น10 = 1000 paisa)
  • Minimum order amount: โ‚น1 (100 paisa)
  • System automatically converts rupees to paisa

Order Expiry

  • Minimum: 300 seconds (5 minutes)
  • Maximum: 3600 seconds (60 minutes)
  • Default: 1800 seconds (30 minutes)
  • Fixed at 30 minutes for optimal user experience

Payment States

  • PENDING: Payment initiated but not completed
  • COMPLETED: Payment successful
  • FAILED: Payment failed

๐Ÿ” Troubleshooting

Common Issues

1. "PhonePe credentials not configured"

  • Solution: Check Client ID and Client Secret in admin configuration

2. "Minimum order amount is โ‚น1"

  • Solution: Ensure cart total is at least โ‚น1

3. "Payment verification failed"

  • Solution: Check PhonePe API credentials and environment setting

4. OAuth token generation failed

  • Solution: Verify Client ID, Client Secret, and network connectivity

5. Route not found errors

  • Solution: Run php artisan route:cache and php artisan config:cache

Debug Logs

Check logs in storage/logs/laravel.log for detailed error information.

๐Ÿ†˜ Support

For support, contact:

๐Ÿ“„ License

This package is proprietary software by Wontonee.

๐Ÿ”ฎ Upcoming Features (Phase 3)

  • โœ… Webhook integration for real-time updates
  • โœ… Refund functionality from admin panel
  • โœ… Order status API integration
  • โœ… Fallback mechanism for missed payments

๐Ÿ“š Additional Resources

Developed with โค๏ธ by Wontonee