1. Go to this page and download the library: Download stablevoy/stablevoy-php 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/ */
stablevoy / stablevoy-php example snippets
use Stablevoy\Client;
use Stablevoy\Model\CreateInvoice;
$stablevoy = Client::create($_ENV['STABLEVOY_API_KEY']);
$created = $stablevoy->invoices()->create(
new CreateInvoice(
amountUsdCents: 2599, // $25.99
externalReference: 'order-1042', // your order id, sent back in webhooks
returnUrl: 'https://shop.example/orders/1042',
),
idempotencyKey: 'order-1042', // a retry returns the same invoice, never a second one
);
header('Location: ' . $created->checkoutUrl);
use Stablevoy\Exception\SignatureException;
use Stablevoy\Webhook\Verifier;
$verifier = new Verifier($_ENV['STABLEVOY_WEBHOOK_SECRET']);
try {
$event = $verifier->verify(file_get_contents('php://input'), $_SERVER['HTTP_X_STABLEVOY_SIGNATURE'] ?? '');
} catch (SignatureException $e) {
http_response_code(400);
exit;
}
if ($event->invoice !== null && $event->invoice->isPaid()) {
// Mark the order $event->invoice->externalReference as paid. Use $event->id to handle each event once.
}
http_response_code(200);
use Stablevoy\ClientOptions;
use Stablevoy\Http\RetryPolicy;
$stablevoy = Client::create($apiKey, new ClientOptions(retries: new RetryPolicy(maxRetries: 3, maxWaitSeconds: 30)));
$stablevoy = Client::create($apiKey, new ClientOptions(), timeoutSeconds: 10);