1. Go to this page and download the library: Download wio/wiopayments library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wio / wiopayments example snippets
use Wio\WioPayments\WioPayments;
$wioPayments = new WioPayments(
apiKey: env('WIOPAYMENTS_API_KEY'),
secretKey: env('WIOPAYMENTS_SECRET_KEY')
);
use Wio\WioPayments\WioPayments;
use Wio\WioPayments\Exceptions\PaymentFailedException;
try {
$wioPayments = new WioPayments(
apiKey: 'your_api_key',
secretKey: 'your_secret_key'
);
$paymentResponse = $wioPayments->charge(
currency: 'USD',
amountInCents: 2999, // $29.99
metadata: [
'customer_id' => 'cust_12345',
'order_id' => 'order_67890',
'description' => 'Premium subscription'
]
);
if ($paymentResponse->isSuccessful()) {
// Payment completed successfully
$paymentId = $paymentResponse->id;
$transactionFee = $paymentResponse->fee;
// Store payment information in your database
// Send confirmation email to customer
echo "Payment processed successfully. ID: {$paymentId}";
} else {
// Payment
// Enable test mode for development
$wioPayments->setTestMode(true);
// Create test payments with specific scenarios
$testPayment = $wioPayments->createTestPayment(
currency: 'USD',
amountInCents: 1000,
scenario: 'success' // 'success', 'failure', 'timeout'
);
// Simulate webhook events for testing
$webhookSimulation = $wioPayments->simulateWebhook(
eventType: 'payment.succeeded',
data: [
'payment_id' => 'test_pay_123',
'amount' => 1000,
'currency' => 'USD'
]
);
// Check if in test mode
if ($wioPayments->isTestMode()) {
echo "Running in test mode - no real charges will be made";
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Wio\WioPayments\WioPayments;
use Wio\WioPayments\Exceptions\PaymentFailedException;
class PaymentController extends Controller
{
public function __construct(
private WioPayments $wioPayments
) {}
public function processPayment(Request $request)
{
$request->validate([
'amount' => 'mer_email,
'user_id' => auth()->id(),
'ip_address' => $request->ip()
]
);
return response()->json([
'success' => true,
'payment_id' => $paymentResponse->id,
'status' => $paymentResponse->status,
'amount' => WioPayments::formatAmount(
$paymentResponse->amount,
$paymentResponse->currency
)
]);
} catch (PaymentFailedException $e) {
return response()->json([
'success' => false,
'error' => 'Payment processing failed',
'message' => $e->getMessage()
], 422);
}
}
}
use Wio\WioPayments\Facades\WioPayments;
// Process payment using facade
$response = WioPayments::charge('USD', 2999);
// Format currency
$formatted = WioPayments::formatAmount(2999, 'USD');