<?php
$cardId = 'crd_8f3a2b1c4d5e6f7890abcdef12345678';
$data = [
'amount' => 50.00,
'reference' => 'my-order-12345' // Optional: your unique reference
];
$ch = curl_init("https://api.fyatu.com/api/v3/cards/{$cardId}/fund");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['success']) {
echo "Funded: $" . $result['data']['amountFunded'] . "\n";
echo "New Balance: $" . $result['data']['newBalance'] . "\n";
echo "Reference: " . $result['data']['reference'] . "\n";
}