imjonos/laravel-yoo-kassa

dev-master 2024-06-10 15:47 UTC

This package is auto-updated.

Last update: 2024-09-10 16:17:20 UTC


README

关于包

基于 SDK yoomoney/yookassa-sdk-php 的 Yookassa 集成。
提供通知 URL /yookassa/notifications
返回支付模型 Nos\Yookassa\Models\YookassaPayment
状态变更事件 Nos\Yookassa\Events\YooKassaPaymentNotification
在应用程序端绑定付款人。

安装

composer require imjonos/laravel-yoo-kassa
php artisan vendor:publish --tag=yookassa.migrations
php artisan migrate

如果需要

php artisan vendor:publish --tag=yookassa.config

如何使用

添加到 .env

YOOKASSA_SHOP_ID=
YOOKASSA_API_KEY=
YOOKASSA_RETURN_URL=

//Фасад
use Nos\Yookassa\Facades\YookassaFacade;
$yookassaPayment = YookassaFacade::createPayment(10, 'test'); 

//Сервис
$service = app(Nos\Yookassa\Services\PaymentService::class);
$yookassaPayment = $service->createPayment(10, 'test');
Класс YookassaPayment
@property string $id
@property string $confirmation_url
@property string $status
@property float $amount
@property string $currency
@property string $description
@property array $metadata
@property int $recipient_account_id
@property int $recipient_gateway_id
@property bool $refundable
@property bool $test

接收通知需要添加 URL

img.png

并订阅事件 Nos\Yookassa\Events\YookassaPaymentNotification

namespace App\Providers;
class EventServiceProvider extends ServiceProvider
...
    protected $listen = [
        YookassaPaymentNotification::class => [
        YookassaPaymentStatus::class
    ]
];
...
namespace App\Listeners;
class YookassaPaymentStatus implements ShouldQueue
...
public function handle(YookassaPaymentNotification $event): void
{
    if ($event->payment->status === PaymentStatus::SUCCEEDED->value) {
    }
}

MIT 许可证

版权所有 (c) 2023 Eugeny Nosenko

在此特此授予任何获得本软件及其相关文档副本(“软件”)的人免费使用软件的权利,不受限制地处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许向软件提供的人以任何方式这样做,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的任何副本或主要部分中。

本软件按“现状”提供,不提供任何形式的保证,无论是明示的、暗示的,还是与特定用途或非侵权相关的保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论该责任源于合同、侵权或其他方式,与软件或其使用或其他方式有关。