1. Go to this page and download the library: Download sonnenglas/yoco-php-sdk 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/ */
sonnenglas / yoco-php-sdk example snippets
use Sonnenglas\Yoco\Client;
use Sonnenglas\Yoco\Dto\CreateCheckoutRequest;
$client = new Client(secretKey: getenv('YOCO_SECRET_KEY'));
$checkout = $client->checkouts()->create(new CreateCheckoutRequest(
amount: 10000, // 100.00 ZAR — Yoco amounts are in cents
currency: 'ZAR',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
metadata: ['orderNumber' => 'ORD-100'],
));
header('Location: '.$checkout->redirectUrl); // send the customer to Yoco