wago-id / php-sdk
Official PHP SDK for WAGO Payment ID
dev-main
2026-07-15 10:55 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2026-07-15 11:02:31 UTC
README
Official PHP SDK untuk layanan pembayaran WAGO Payment ID.
Instalasi
Gunakan Composer:
composer require wago-id/php-sdk
Penggunaan
Inisialisasi
require 'vendor/autoload.php'; use Wago\Wago; $wago = new Wago([ 'appId' => 'APP_ID_ANDA', 'apiKey' => 'API_KEY_ANDA', 'webhookSecret' => 'WEBHOOK_SECRET_ANDA' // Opsional, diperlukan untuk validasi webhook ]);
Membuat Transaksi
try { $trx = $wago->createTransaction([ 'order_id' => 'INV-' . time(), 'nominal' => 150000, 'customer_name' => 'Budi Santoso', 'payment_method' => 'QRIS', 'is_sandbox' => true ]); print_r($trx); } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Memvalidasi Webhook
$headers = getallheaders(); $signature = $headers['X-WAGO-Signature'] ?? ''; $timestamp = $headers['X-WAGO-Timestamp'] ?? ''; $rawBody = file_get_contents('php://input'); $body = json_decode($rawBody, true); if ($wago->verifyWebhook($body, $signature, $timestamp)) { http_response_code(200); echo json_encode(["status" => "ok"]); } else { http_response_code(403); echo json_encode(["error" => "Invalid signature"]); }