Magento 2: how to use DwollaSwagger.php class from lib folder?

Viewed 22

I want to implement dwolla payment gateway in my current project, I have added DwollaSwagger (core PHP) library in "lib/internal" folder and trying to access DwollaSwagger methods from "block class" getting errors like this.

main.CRITICAL: Error: Class 'Demo\Dwolla\Block\Demo\DwollaSwagger' not found in app/code/Demo/Dwolla/Block/Demo/Customer.php:30

Block class (Customer.php):

<?php
declare(strict_types=1);
namespace Demo\Dwolla\Block\Demo;
require(BP.'/lib/internal/dwolla/dwollaswagger/DwollaSwagger.php');
class Customer extends \Magento\Framework\View\Element\Template
{
    protected $request;
    protected $dir;
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\Framework\App\Request\Http $request,
        \Magento\Framework\Filesystem\DirectoryList $dir,
        array $data = []
    ) {
        $this->request = $request;
         $this->dir = $dir;
        parent::__construct($context, $data);
    }
    public function getTokenID(){        
       $DwollaSwagger = new DwollaSwagger();
       DwollaSwagger\Configuration::$username = 'xxxxxxxxxxxxxxxxxxx';
       DwollaSwagger\Configuration::$password = 'xxxxxxxxxxxxxxxxxxx';

       // For Sandbox
       $apiClient = new DwollaSwagger\ApiClient("https://api-sandbox.dwolla.com");
       $tokensApi = new DwollaSwagger\TokensApi($apiClient);
       $appToken = $tokensApi->token();
       return $appToken;
    }
}

?>

lib folder structure: lib -internal -dwolla -dwollaswagger -lib(dwollaswagger library) -DwollaSwagger.php enter image description here

Please help me, Thanks in advance.

0 Answers
Related