fersaku/fersaku-php
Composer 安装命令:
composer require fersaku/fersaku-php
包简介
Official Fersaku QRIS Payment Gateway SDK for PHP
README 文档
README
Official PHP SDK untuk Fersaku QRIS Payment Gateway.
Instalasi
composer require fersaku/fersaku-php
Atau copy folder src/ langsung ke project Anda.
Quick Start
<?php require_once 'vendor/autoload.php'; use Fersaku\Fersaku; $fersaku = new Fersaku('sk_live_your_secret_key'); // Buat pembayaran $payment = $fersaku->createPayment([ 'amount' => 50000, 'customer_name' => 'John Doe', 'customer_email' => 'john@example.com', 'description' => 'Pembelian Produk A', 'external_id' => 'order-123', 'expired_minutes' => 30, ]); echo $payment['checkout_url']; // Redirect customer ke sini echo $payment['qr_string']; // Atau tampilkan QR langsung
API Methods
createPayment(array $params)
Buat pembayaran QRIS baru.
$payment = $fersaku->createPayment([ 'amount' => 100000, // Wajib, min 1000 'customer_name' => 'Budi', // Opsional 'customer_email' => 'budi@email.com', // Opsional 'description' => 'Order #123', // Opsional 'external_id' => 'my-order-123', // Opsional 'expired_minutes' => 30, // Opsional, default 30 ]);
getPayment(string $id)
Ambil detail pembayaran.
$detail = $fersaku->getPayment('payment_id_here');
listPayments(array $params)
List pembayaran dengan filter.
$list = $fersaku->listPayments(['status' => 'paid', 'limit' => 10]);
cancelPayment(string $id)
Batalkan pembayaran pending.
$fersaku->cancelPayment('payment_id_here');
checkStatus(string $id)
Cek status terbaru.
$result = $fersaku->checkStatus('payment_id_here');
simulate(string $paymentId, string $action) (Sandbox only)
Simulasi pembayaran di sandbox.
$sandbox = new Fersaku('sk_test_your_sandbox_key'); $sandbox->simulate('payment_id', 'pay'); // pay, expire, fail, cancel
Webhook Verification
<?php use Fersaku\Fersaku; // Laravel Controller public function handleWebhook(Request $request) { $signature = $request->header('X-Webhook-Signature'); $webhookSecret = env('FERSAKU_WEBHOOK_SECRET'); $isValid = Fersaku::verifyWebhook( $request->all(), $signature, $webhookSecret ); if (!$isValid) { return response()->json(['message' => 'Unauthorized'], 401); } $event = $request->input('event'); $paymentId = $request->input('payment_id'); $orderId = $request->input('order_id'); $status = $request->input('status'); $amount = $request->input('amount'); if ($event === 'payment.paid') { // Proses pembayaran berhasil // Update order di database Anda } return response()->json(['message' => 'OK']); }
Native PHP (tanpa framework)
<?php require_once 'src/Fersaku.php'; use Fersaku\Fersaku; $payload = json_decode(file_get_contents('php://input'), true); $signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? ''; $webhookSecret = 'whsec_your_secret_here'; if (!Fersaku::verifyWebhook($payload, $signature, $webhookSecret)) { http_response_code(401); echo json_encode(['message' => 'Unauthorized']); exit; } if ($payload['event'] === 'payment.paid') { // Proses pembayaran berhasil } http_response_code(200); echo json_encode(['message' => 'OK']);
Sandbox vs Production
// Production $live = new Fersaku('sk_live_xxx'); // Sandbox (testing) $sandbox = new Fersaku('sk_test_xxx');
Error Handling
use Fersaku\Fersaku; use Fersaku\FersakuException; try { $payment = $fersaku->createPayment(['amount' => 500]); } catch (FersakuException $e) { echo $e->getMessage(); // "Amount must be at least Rp 1.000" echo $e->getCode(); // 400 print_r($e->getData()); // Full error response }
Publish ke Packagist
- Push ke GitHub
- Buka https://packagist.org
- Submit repository URL
- Done — user bisa
composer require fersaku/fersaku-php
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-12