yoco/yoco-php-laravel
最新稳定版本:v0.1.0-beta
Composer 安装命令:
composer require yoco/yoco-php-laravel
包简介
Yoco PHP Library for Laravel
README 文档
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
ChargeControllerdeployed 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.
统计信息
- 总下载量: 6.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2021-08-06