PHP Examples
Complete PHP integration examples for AuxVault API.
Installation
composer require auxvault/php-sdk
Setup
<?php
require 'vendor/autoload.php';
use AuxVault\Client;
$client = new Client([
'api_key' => getenv('LUQRA_API_KEY'),
'tenant_id' => getenv('LUQRA_TENANT_ID'),
'environment' => getenv('APP_ENV') === 'production' ? 'production' : 'sandbox'
]);
Process Payment
<?php
try {
$transaction = $client->transactions->create([
'type' => 'sale',
'amount' => 100.00,
'currency' => 'USD',
'card' => [
'number' => '4111111111111111',
'expiry_month' => '12',
'expiry_year' => '2027',
'cvv' => '123'
],
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address' => '123 Main St',
'city' => 'New York',
'state' => 'NY',
'zip' => '10001',
'country' => 'US'
],
'customer' => [
'email' => 'john@example.com'
]
]);
echo "Transaction approved: " . $transaction->id;
} catch (\AuxVault\Exceptions\TransactionDeclinedException $e) {
echo "Payment declined: " . $e->getMessage();
} catch (\Exception $e) {
echo "Error: " . $e->getMessage();
}
Webhook Handler
<?php
// webhook.php
require 'vendor/autoload.php';
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_LUQRA_SIGNATURE'];
if (!$client->webhooks->verify($payload, $signature)) {
http_response_code(401);
die('Invalid signature');
}
$event = json_decode($payload, true);
switch ($event['type']) {
case 'transaction.approved':
handleTransactionApproved($event['data']);
break;
case 'transaction.declined':
handleTransactionDeclined($event['data']);
break;
}
http_response_code(200);
function handleTransactionApproved($data) {
// Update order, send receipt
}
Next: Python examples →