wiopayments / php-sdk-vanilla
WioPayments Gateway PHP SDK - Vanilla PHP Version (No Dependencies)
v1.0.0
2025-05-28 16:37 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.0|^10.0
This package is not auto-updated.
Last update: 2025-05-29 14:52:00 UTC
README
A standalone PHP library for integrating with WioPayments Gateway. No dependencies required - works with any PHP project without Composer or external libraries.
๐ Quick Start
1. Download and Include
// Simply include the main SDK file require_once 'WioPayments.php'; // Initialize with your API key $wioPayments = new WioPayments('your_api_key_here');
2. Create a Simple Payment
// Create payment data $paymentData = [ 'amount' => 50.00, 'currency' => 'USD', 'order_id' => 'ORDER_' . uniqid(), 'customer' => [ 'name' => 'John Doe', 'email' => 'john@example.com' ] ]; // Create payment and get client secret $payment = $wioPayments->createPayment($paymentData); // Generate complete payment form $paymentForm = $wioPayments->renderPaymentForm($paymentData); file_put_contents('payment.html', $paymentForm);
3. Check Payment Status
$status = $wioPayments->getPaymentStatus($payment->id); echo "Payment status: " . $status->status;
๐ Features
- โ Zero Dependencies - Pure PHP, no Composer required
- โ Complete Payment Forms - Ready-to-use HTML with Stripe integration
- โ Hosted Payment Pages - Redirect customers to secure payment pages
- โ Payment Links - Create shareable payment URLs
- โ JavaScript Integration - Add payments to existing pages
- โ Multi-Currency Support - USD, EUR, TRY, GBP
- โ Real-time Status - Check payment status anytime
- โ Customizable UI - Custom CSS and styling options
๐ ๏ธ Installation Methods
Method 1: Direct Download (Recommended)
# Download the single file
wget https://github.com/WioPayments/agent-php-vanilla/archive/refs/tags/v1.0.0.zip
Method 2: Copy and Paste
Simply copy the WioPayments.php
file to your project directory.
Method 3: Include in Existing Projects
// Add to your existing PHP application include_once '/path/to/WioPayments.php';
๐ Usage Examples
Complete Payment Form
<?php require_once 'WioPayments.php'; $wioPayments = new WioPayments('your_api_key'); $paymentData = [ 'amount' => 99.99, 'currency' => 'USD', 'order_id' => 'ORDER_123', 'description' => 'Premium Product', 'customer' => [ 'name' => 'Customer Name', 'email' => 'customer@email.com' ] ]; // Generate complete payment page $paymentForm = $wioPayments->renderPaymentForm($paymentData, [ 'submit_button_text' => 'Pay $99.99', 'success_url' => 'https://yoursite.com/success', 'custom_css' => '.wiopayments-button { background: #28a745; }' ]); echo $paymentForm; ?>
Hosted Payment Redirect
<?php require_once 'WioPayments.php'; $wioPayments = new WioPayments('your_api_key'); $sessionData = [ 'amount' => 75.00, 'currency' => 'USD', 'order_id' => 'ORDER_456', 'success_url' => 'https://yoursite.com/success', 'cancel_url' => 'https://yoursite.com/cancel', 'customer' => [ 'name' => 'Jane Smith', 'email' => 'jane@email.com' ] ]; // Get payment URL and redirect $paymentUrl = $wioPayments->createHostedPaymentUrl($sessionData); header('Location: ' . $paymentUrl); exit; ?>
Existing Page Integration
<?php require_once 'WioPayments.php'; $wioPayments = new WioPayments('your_api_key'); // Create payment $payment = $wioPayments->createPayment($paymentData); // Get JavaScript code $script = $wioPayments->generatePaymentScript($payment->id); ?> <!DOCTYPE html> <html> <head> <title>Your Existing Page</title> </head> <body> <h1>Your Product</h1> <div id="payment-container"></div> <script> <?php echo $script; ?> // Your existing JavaScript window.wioPaymentsReady = function() { const paymentForm = window.WioPayments.createPaymentForm('payment-container'); // Handle payment confirmation... }; </script> </body> </html>
Payment Links
<?php require_once 'WioPayments.php'; $wioPayments = new WioPayments('your_api_key'); // Create payment link $linkData = [ 'amount' => 25.00, 'currency' => 'USD', 'description' => 'Digital Product', 'max_uses' => 1, 'expires_at' => date('Y-m-d H:i:s', strtotime('+7 days')) ]; $paymentLink = $wioPayments->createPaymentLink($linkData); echo "Share this payment link: " . $paymentLink['url']; // List all payment links $allLinks = $wioPayments->listPaymentLinks(); foreach ($allLinks['data'] as $link) { echo $link['description'] . ": " . $link['url'] . "\n"; } ?>
๐ง Configuration Options
$wioPayments = new WioPayments('your_api_key', [ 'base_url' => 'https://gw.wiopayments.com', 'timeout' => 30, 'verify_ssl' => true ]);
๐จ Customization
Custom Payment Form Styling
$paymentForm = $wioPayments->renderPaymentForm($paymentData, [ 'custom_css' => ' .wiopayments-form { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; } .wiopayments-button { background: linear-gradient(45deg, #007bff, #0056b3); border-radius: 25px; } .wiopayments-card-element { border: 2px solid #007bff; } ' ]);
Form Customization Options
$options = [ 'submit_button_text' => 'Complete Purchase', 'loading_button_text' => 'Processing Payment...', 'success_url' => 'https://yoursite.com/thank-you', 'cancel_url' => 'https://yoursite.com/checkout', 'form_id' => 'my-payment-form', 'card_element_id' => 'my-card-element', 'error_element_id' => 'my-error-element' ];
๐ Security
- All payments are processed securely through Stripe
- No sensitive payment data touches your server
- PCI DSS compliant by design
- SSL/TLS encryption for all API communication
๐ฐ Supported Currencies
- USD (US Dollar)
- EUR (Euro)
- TRY (Turkish Lira)
- GBP (British Pound)
๐ฑ Browser Support
- Chrome 60+
- Firefox 60+
- Safari 11+
- Edge 16+
- Mobile browsers (iOS Safari, Chrome Mobile)
๐ Error Handling
try { $payment = $wioPayments->createPayment($paymentData); echo "Payment created: " . $payment->id; } catch (WioPaymentsException $e) { echo "Payment error: " . $e->getMessage(); echo "Error code: " . $e->getCode(); } catch (Exception $e) { echo "Unexpected error: " . $e->getMessage(); }
๐ Payment Status Values
pending
- Payment created, awaiting customer actionprocessing
- Payment is being processedsucceeded
- Payment completed successfullyfailed
- Payment failed or was declinedcanceled
- Payment was canceled by customer
๐ API Endpoints
The vanilla PHP SDK communicates with these WioPayments API endpoints:
POST /api/v1/create-payment
- Create new paymentGET /api/v1/payment/{id}/status
- Get payment statusPOST /api/v1/hosted/sessions
- Create hosted payment sessionPOST /api/v1/payment-links
- Create payment linkGET /api/v1/payment-links
- List payment links
๐งช Testing
Test API Key
wio_KTXPsDbGOBDCjQGA5axcIR0JJy2E9Pkj
Test Cards
Success: 4242424242424242
Declined: 4000000000000002
Test Environment
https://gw.wiopayments.com/test-payment.html
๐ Version Information
- Version: 1.0.0
- PHP Requirements: PHP 7.4+
- Dependencies: None (uses cURL for HTTP requests)
- License: MIT
๐ Migration from Composer Version
If you're currently using the Composer version, migration is simple:
// Old way (Composer) use WioPayments\Client; $client = new Client('api_key'); // New way (Vanilla) require_once 'WioPayments.php'; $client = new WioPayments('api_key'); // All methods remain the same! $payment = $client->createPayment($data);
๐ก Tips and Best Practices
- Always validate payment data before creating payments
- Use HTTPS in production for security
- Store payment IDs for transaction tracking
- Handle errors gracefully with try-catch blocks
- Test with small amounts before going live
- Keep your API key secure and never expose it in frontend code
๐ Support
- ๐ง Email: support@wiopayments.com
- ๐ Documentation: https://docs.wiopayments.com
- ๐ Test Environment: https://gw.wiopayments.com/test-payment.html
Ready to start accepting payments?
- Get your API key from the WioPayments dashboard
- Download
WioPayments.php
- Follow the quick start guide above
- Start processing payments in minutes!
No credit card required for testing. Use our test API key and test cards to get started immediately.