Polar Payment Gateway by ALT
Accept payments via Polar.sh Checkout – Standalone WordPress payment solution without WooCommerce dependency.
Author: Nam Truong
Website: https://namncn.com
Plugin URI: https://namncn.com/product/alt-polar-payment-gateway
Features
- ✅ Standalone solution – No WooCommerce required
- 💳 Complete Polar.sh Checkout API integration
- 🔄 Subscription support for recurring payments
- 💰 Dynamic pricing with ad-hoc prices
- 🎨 Customizable payment forms via shortcodes
- 📊 Order management dashboard
- 🔔 Webhook support for payment confirmation
- 💱 Multi-currency support (USD, EUR, GBP, VND)
- 🐛 Debug logging
- 🌐 Translation ready
Requirements
- WordPress 5.8+
- PHP 7.4+
- Polar.sh account with Access Token
Installation
- Upload plugin folder to
/wp-content/plugins/ - Activate the plugin through WordPress admin
- Go to Polar Orders → Settings
- Configure your Polar API credentials
Quick Setup
Step 1: Get Polar Access Token
- Go to https://polar.sh → Settings → API Tokens
- Create new token with checkout permissions
- Copy the Access Token
Step 2: Create Product on Polar
- Go to https://polar.sh → Products → Create Product
- Set price type to “Pay what you want” or “Custom”
- Copy the Product ID (format:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
Step 3: Configure Plugin
- Polar Orders → Settings
- Enter:
- Polar Access Token: Your API token from Step 1
- Product Mapping: Select “Single Product + Dynamic Pricing”
- Default Product ID: Product ID from Step 2
- Success URL: URL to redirect after payment (e.g.,
/payment-success/)
- Save changes
Step 4: Setup Webhook
- Copy Webhook URL from settings page sidebar
- Go to Polar Dashboard → Settings → Webhooks
- Add new webhook endpoint with the copied URL
- Select events:
checkout.updated,order.created,subscription.created
Usage
Basic Payment Form
[polar_payment_form]
This creates a complete payment form with customer name, email, and amount fields.
Fixed Amount Payment
[polar_payment_form amount="99.99" currency="usd" show_amount="no"]
Create a form with pre-defined amount (amount field hidden from user).
Specific Product
[polar_payment_form product_id="YOUR_PRODUCT_ID"]
Use a specific Polar Product ID instead of the default one.
Custom Button Text
[polar_payment_form button_text="Subscribe Now" amount="29.99"]
Without Custom Fields
[polar_payment_form custom_fields="no"]
Hide the optional note field.
Complete Example
[polar_payment_form
amount="49.99"
currency="usd"
product_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
button_text="Join Premium"
show_amount="no"
custom_fields="no"]
Shortcode Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
amount |
number | – | Payment amount (optional if user-entered) |
currency |
string | usd |
Currency code (usd, eur, gbp, vnd) |
product_id |
string | – | Specific Polar Product ID |
button_text |
string | “Pay Now” | Submit button text |
show_amount |
string | yes |
Show/hide amount field (yes/no) |
custom_fields |
string | yes |
Show/hide note field (yes/no) |
Product Mapping Modes
1. Single Product + Dynamic Pricing (Recommended)
Uses one Polar Product with dynamically calculated prices based on payment amount.
Best for: Most use cases, donations, flexible pricing
2. Single Product
Uses one Polar Product with fixed catalog price from Polar.
Best for: Fixed-price products, subscriptions
3. Custom
Allows each shortcode to specify its own product_id parameter.
Best for: Multiple products, advanced setups
Order Management
View Orders
Navigate to Polar Orders in WordPress admin to view all payment orders.
Order Details
Each order shows:
- Order ID
- Customer information
- Payment amount and currency
- Polar Checkout ID
- Subscription ID (if applicable)
- Payment status
- Timestamps
Order Statuses
- Pending – Order created, awaiting payment
- Processing – Payment in progress
- Completed – Payment successful
- Failed – Payment failed
- Cancelled – Order cancelled
Webhook Events
The plugin handles these Polar webhook events:
checkout.updated– Payment status updatedorder.created– Order completedsubscription.created– Recurring subscription created
Development Hooks
Actions
// Fired when payment is completed
do_action('polar_payment_completed', $order, $webhook_data);
// Fired when subscription is created
do_action('polar_subscription_created', $order, $webhook_data);
Example Usage
add_action('polar_payment_completed', 'my_custom_handler', 10, 2);
function my_custom_handler($order, $data) {
// Send custom email
// Update user meta
// Trigger other integrations
error_log('Payment completed: ' . $order->order_id);
}
Database Schema
The plugin creates a custom table wp_polar_orders with these fields:
id– Auto-increment primary keyorder_id– Unique order identifiercustomer_email– Customer emailcustomer_name– Customer nameamount– Payment amountcurrency– Currency codestatus– Order statuspolar_checkout_id– Polar checkout session IDpolar_checkout_url– Checkout page URLpolar_subscription_id– Subscription ID (if applicable)metadata– JSON metadatacreated_at– Created timestampupdated_at– Updated timestamp
Troubleshooting
Error: Access Token not configured
Solution: Enter your Polar Access Token in plugin settings.
Error: Product ID is not configured
Solution:
- Create a product on Polar.sh
- Copy the Product ID
- Enter it in plugin settings
Webhook not working
Solutions:
- Verify webhook URL is correctly added in Polar Dashboard
- Check that your site is accessible from the internet (webhooks won’t work on localhost)
- Enable debug mode and check logs at
wp-content/polar-payment.log
Payments not completing automatically
Solutions:
- Ensure webhook is properly configured
- Check webhook events include
checkout.updatedandorder.created - Enable debug logging to see webhook requests
Debug Logging
- Go to Polar Orders → Settings
- Enable Debug Mode
- Check logs at
wp-content/polar-payment.log
Security
- All user inputs are sanitized and validated
- Nonce verification on all AJAX requests
- SQL injection prevention with prepared statements
- XSS protection with proper escaping
- Secure API communication via HTTPS
Support
- Polar Documentation: https://docs.polar.sh
- Polar Dashboard: https://polar.sh/dashboard
- Plugin Support: support@namncn.com
License
GPL v2 or later
Changelog
1.0.0 (2026-02-06)
- 🎉 Initial release
- ✨ Standalone payment gateway (no WooCommerce)
- ✨ Shortcode-based payment forms
- ✨ Custom order management system
- ✨ Webhook integration
- ✨ Subscription support
- ✨ Multi-currency support
- ✨ Admin dashboard
- ✨ Debug logging
- 🌐 Translation ready
Credits
Based on the WooCommerce version of Polar Payment Gateway, adapted for standalone WordPress use.
Developed with ❤️ by Nam Truong

Đánh giá
Chưa có đánh giá nào.