Libraries

yoco-php

The Yoco PHP client library provides access to the Yoco Online Payments API from PHP. It does this by providing client classes and associated method calls that abstract the underlying Yoco API requests, responses and errors.

Install the library with Composer:

composer require yoco/yoco-php

To use the library:

require_once('vendor/autoload.php');
// Initialize the client with your keys
$client = new \Yoco\YocoClient($secret_key, $public_key);
try{
// use the token received from the Web SDK
$client->charge($token, $amount_in_cents, $currency);
} catch (\Yoco\Exceptions\ApiKeyException $e) {
error_log("API keys incorrect: " . $e->getMessage());
} catch (\Yoco\Exceptions\DeclinedException $e) {
error_log("Charge declined with error: " . $e->getMessage());
} catch (\Yoco\Exceptions\InternalException $e) {
error_log("Unknown error: " . $e->getMessage());
}

yoco-php-laravel

The Yoco Laravel package is a Laravel-friendly library which wraps the Yoco PHP client library to provide access to the Yoco Online Payments API from PHP. It does this by providing a ChargeController and associated routes that can be called from the JavaScript front-end.

Install the library with Composer:

# Composer install
composer require yoco/yoco-php-laravel
# Publish config and charge controller
php artisan vendor:publish --tag=yoco