Pix Wallet is a comprehensive WordPress plugin that implements a credit-based payment system integrated with OpenPix (Brazilian PIX payment system). Users can purchase credits and spend them to publish posts, creating a monetization system for WordPress content creators.
- Credit Balance Management: Real-time user balance tracking with caching
- OpenPix Integration: Seamless PIX payment processing
- Transaction System: Complete audit trail of all credit operations
- Post Publication Control: Credit verification before post publication
- Package System: Pre-defined credit packages with bonus calculations
- Notification System: Email notifications for purchases and low balance warnings
- Analytics Dashboard: Comprehensive reporting and analytics
- Performance Optimization: Advanced caching and query optimization
- Security Features: CSRF protection, input sanitization, and rate limiting
- Purchase credits via PIX payments
- View transaction history
- Set up auto-recharge preferences
- Receive balance notifications
- Export transaction data
- Manage credit packages and pricing
- Monitor system performance
- Generate financial reports
- Configure OpenPix settings
- Manage user balances
- View webhook logs
- WordPress: 5.0 or higher
- PHP: 7.4 or higher (8.0+ recommended)
- MySQL: 8.0+ or MariaDB 10.5+
- OpenPix Account: For payment processing
- SSL Certificate: Required for secure webhook processing
- Upload the plugin zip file through WordPress admin
- Activate the plugin
- Go to Pix Wallet > Settings to configure
- Extract the plugin files to
/wp-content/plugins/pix-wallet/
- Activate the plugin through the WordPress admin interface
- Configure the plugin settings
- Create an OpenPix account at openpix.com.br
- Get your App ID and API credentials
- Configure webhook URL in your OpenPix dashboard
- Enter credentials in Pix Wallet > OpenPix Settings
- Set credit cost per post
- Configure minimum balance requirements
- Enable/disable negative balance
- Set currency preferences
- Create credit packages with pricing
- Set bonus credit percentages
- Configure package display order
- Mark popular packages
- Visit the credit purchase page
- Select a credit package
- Complete PIX payment
- Credits are automatically added to balance
- Create post content as usual
- System checks credit balance before publication
- Credits are automatically deducted on publish
- Insufficient balance blocks publication
- View current balance in admin bar
- Check transaction history
- Set up auto-recharge preferences
- Receive low balance notifications
// Create a new credit package
$package_data = array(
'credits' => 1000,
'price' => 9900, // R$ 99.00 in cents
'bonus_credits' => 100,
'name' => '1000 Credits + 100 Bonus'
);
// Add credits to user
$balance_manager = new Pix_Wallet_Balance_Manager();
$balance_manager->add_credits($user_id, $amount, $transaction_id);
// Check user balance
$balance = $balance_manager->get_user_balance($user_id);
// Create transaction
$transaction_handler = new Pix_Wallet_Transaction_Handler();
$transaction_id = $transaction_handler->create_purchase_transaction($user_id, $amount, $openpix_data);
class Pix_Wallet_Balance_Manager {
public function get_user_balance($user_id);
public function add_credits($user_id, $amount, $transaction_id);
public function deduct_credits($user_id, $amount, $transaction_id);
public function has_sufficient_balance($user_id, $amount);
public function validate_balance_integrity($user_id);
}
class Pix_Wallet_Transaction_Handler {
public function create_transaction($transaction_data);
public function create_purchase_transaction($user_id, $amount, $openpix_data);
public function create_spend_transaction($user_id, $amount, $post_id);
public function update_transaction_status($transaction_id, $status);
public function get_user_transactions($user_id, $filters = array());
}
class Pix_Wallet_OpenPix_Integration {
public function create_charge($amount, $user_id, $description);
public function get_charge_status($charge_id);
public function cancel_charge($charge_id);
public function refund_charge($charge_id, $amount);
public function validate_api_credentials();
}
// Fired when credits are added to user balance
do_action('pix_wallet_credits_added', $user_id, $amount, $transaction_id);
// Fired when credits are deducted
do_action('pix_wallet_credits_deducted', $user_id, $amount, $transaction_id);
// Fired when transaction is completed
do_action('pix_wallet_transaction_completed', $transaction_id, $transaction_data);
// Fired when payment fails
do_action('pix_wallet_payment_failed', $transaction_id, $reason);
// Modify post cost calculation
$cost = apply_filters('pix_wallet_post_cost', $cost, $post_data, $user_id);
// Modify package pricing
$price = apply_filters('pix_wallet_package_price', $price, $package_id, $user_id);
// Modify balance display
$display = apply_filters('pix_wallet_balance_display', $balance, $user_id);
// Modify notification content
$content = apply_filters('pix_wallet_notification_content', $content, $type, $user_id);
[pix_wallet_purchase]
// Display credit packages for purchase
[pix_wallet_purchase package_id="123"]
// Display specific package
[pix_wallet_purchase show_popular="true"]
// Show only popular packages
[pix_wallet_balance]
// Show current user balance
[pix_wallet_balance show_history="true"]
// Include transaction history link
[pix_wallet_balance format="detailed"]
// Show detailed balance information
[pix_wallet_history]
// Show user transaction history
[pix_wallet_history limit="20"]
// Limit number of transactions shown
[pix_wallet_history type="purchase"]
// Show only purchase transactions
post_title
: Unique transaction IDpost_content
: Transaction detailspost_author
: User IDpost_status
: Transaction status (pending, completed, failed, cancelled)
Meta Fields:
_pix_transaction_type
: purchase, spent, refund, bonus_pix_credit_amount
: Credit amount_pix_user_id
: User ID_pix_related_post_id
: Related post ID (if applicable)_pix_openpix_charge_id
: OpenPix charge ID_pix_payment_value
: Payment value in cents
post_title
: Package namepost_content
: Package descriptionpost_status
: Active/inactive
Meta Fields:
_pix_package_credits
: Credit amount_pix_package_price
: Price in cents_pix_package_bonus_credits
: Bonus credits_pix_package_order
: Display order
_pix_wallet_balance
: Current credit balance_pix_wallet_total_purchased
: Total credits purchased_pix_wallet_total_spent
: Total credits spent_pix_wallet_notifications
: Notification preferences_pix_wallet_auto_recharge
: Auto-recharge settings
- All user inputs are sanitized and validated
- SQL injection prevention through prepared statements
- XSS prevention through output escaping
- CSRF token validation for all forms
- Nonce verification for admin actions
- User capability checks
- Signature validation for OpenPix webhooks
- IP filtering for webhook endpoints
- Request rate limiting
- User balance caching with automatic invalidation
- Transaction summary caching
- Package data caching
- Database query optimization
- Proper indexing on frequently queried fields
- Optimized queries for balance calculations
- Query result pagination for large datasets
- WordPress cron for heavy operations
- Async notification sending
- Batch processing for bulk operations
The plugin includes comprehensive test coverage:
- Unit Tests: Individual class testing
- Integration Tests: Complete workflow testing
- Security Tests: Vulnerability testing
- Performance Tests: Benchmark testing
# Run all tests
phpunit --configuration phpunit.xml
# Run specific test suite
phpunit tests/unit/
phpunit tests/integration/
phpunit tests/security/
phpunit tests/performance/
# Generate coverage report
phpunit --coverage-html coverage/
- Check webhook configuration in OpenPix dashboard
- Verify webhook URL is accessible
- Check webhook logs in admin panel
- Ensure SSL certificate is valid
- Clear plugin cache
- Verify transaction status
- Check user permissions
- Run balance integrity check
- Check user credit balance
- Verify minimum balance settings
- Check category-specific pricing
- Review error logs
Enable debug mode to see detailed error information:
define('PIX_WALLET_DEBUG', true);
Check these logs for troubleshooting:
- WordPress debug log
- Plugin-specific logs in
/wp-content/uploads/pix-wallet-logs/
- Server error logs
- GitHub Issues: Report bugs and feature requests
- WordPress.org Support Forum: Community support
- Initial release
- Complete credit system implementation
- OpenPix integration
- Admin dashboard
- Performance optimization
- Comprehensive testing suite
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
# Clone repository
git clone https://github.com/your-username/pix-wallet.git
# Install dependencies
composer install
# Run tests
phpunit
# Run code standards check
phpcs --standard=WordPress .
This plugin is licensed under the GPL v2 or later.
- OpenPix API integration
- WordPress Plugin Boilerplate
- Chart.js for analytics
- PHPUnit for testing
For more information, visit the plugin documentation or contact support.