ravols/laravel-everifin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ravols/laravel-everifin

最新稳定版本:0.1.3

Composer 安装命令:

composer require ravols/laravel-everifin

包简介

This is my package laravel-everifin

README 文档

README

image image

image

This package serves as a Laravel bridge, enabling the seamless creation and management of payments through the Everifin payment gateway. It is built upon the original PHP SDK from Everifin, ensuring robust functionality and compatibility. Check the PHP SDK here.

Installation

You can install the package via composer:

composer require ravols/laravel-everifin

You can publish the config file with:

php artisan vendor:publish --tag="laravel-everifin-config"

This is the contents of the published config file:

return [
    'client_id' => env('EVERIFIN_CLIENT_ID'),
    'client_secret' => env('EVERIFIN_CLIENT_SECRET'),
    'client_iban' => env('EVERIFIN_CLIENT_IBAN'),
];

You can use this config values when setting up your Config instance.

Usage

To begin, you need to create an instance of your Config class. This instance is designed as a singleton, meaning it's only instantiated once during the lifecycle of your application. The reason it's not globally defined in a provided service is to cater for situations where your project supports multiple e-commerce sites and requires dynamic configuration value changes.

In most cases, adhere to the following approach:

<?php
use Ravols\EverifinPhp\Config;
use Ravols\LaravelEverifin\Facades\LaravelEverifinOrders;

class EverifinPaymentProcessor {

    public function __construct()
    {
        Config::getInstance()->setClientSecret(config('everifin.client_secret'))->setClientIban(config('everifin.client_iban'))->setClientId(config('everifin.client_id'));
    }

    public function createPaymentLink(Order $order): string
    {
      //Your logic for ecommerce orders
      $responseData = LaravelEverifinOrders::createPayment(
            amount: 120.99,
            currency: 'EUR',
            redirectUrl: 'https://my-domain/payment/' . $order->number,
            recipientIban: Config::getInstance()->getClientIban(),
            message: 'My message',
            email: $order->user->email,
            recipientName: 'My company name',
            variableSymbol: 'Variable symbol', //For non CZ and SK sites use reference field
        );

        //$responseData contains much more than a link, feel free to check it out
        return $responseData->link;
    }
}

Once the payment is paid for or cancelled on the payment gateway, customer is redirect back to the redirectUrl that you provided in the createPayment method. Now, you need to retrieve the payment status and handle your order as you wish.

You can retireve the payment ID as it's always send back to the redirect url as a get parameter ID or store it in a database during payment creation from the $responseData above.

    use Ravols\LaravelEverifin\Facades\LaravelEverifinPayments;
    use Ravols\EverifinPhp\Exceptions\ResponseException;
    //Your logic in class

    //Get payment status
    try {
        $paymentStatus = LaravelEverifinPayments::getPayment(paymentId: request()->id);
    } catch (ResponseException $e) {
        $errors = collect($e->errors); //Here you can find errors from Everifin gateway in case request fails
        //Your logic for handling error cases
    }
    //Your logic with ifs, switch cases or any other way
    if($paymentStatus === 'BOOKED')
    {
        //Complete order logic
    }

    if($paymentStatus === 'FAILED')
    {
        //Handle error statuses.
    }

List of all statuses can be found on the documentation page.

List of error codes and their descriptions can be found on the documentation page.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 84
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固