yoco / yoco-php-laravel
Yoco PHP Library for Laravel
Installs: 3 401
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: >=7.0
- yoco/yoco-php: 0.1.0-beta
This package is not auto-updated.
Last update: 2024-04-27 20:24:27 UTC
README
This 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 frontend.
This library is used in conjunction with the frontend Web SDK described here which securely captures the customer's card details and generates the required token.
Put simply, the process is:
- Securely capture card details using the Web SDK, which then provides a charge token
- Send the charge token to your Laravel backend application and finalise the charge via the
ChargeController
deployed by this library
A full sample implementation of the Web SDK in vanilla PHP and Laravel is available here.
For more information on the APIs, you can refer to the Yoco API Docs.
Requirements
- PHP 7.0 and later
- Laravel 7+
Installation
Install the library into your Laravel application with Composer and publish core files:
# Composer install composer require yoco/yoco-php-laravel # Publish config and charge controller php artisan vendor:publish --tag=yoco
The above installation will add the files /config/yoco.php
and /app/Http/Controllers/ChargeController.php
to your source tree and also add the route /yoco/charge
to your route list.
Setup your keys
Edit the file /config/yoco.php
and set the secret and public keys you received from the Yoco Business Portal.
Making a purchase
A simple example is as follows:
- The frontend Web SDK has been used to capture the card details, amount and currency as described in the SDK docs.
- The frontend makes an AJAX request to your charge route
/yoco/charge
, which is processed by yourChargeController
. - The result will be returned to your frontend as JSON.
Yoco API Documentation
See the API docs.