dimafe6 / bank-id

BankID
MIT License
30 stars 26 forks source link

Error: Class 'Dimafe6\BankID\Service\Controller' not found #10

Closed codeom closed 2 years ago

codeom commented 3 years ago

I'm getting an error in my file which says Error: Class 'Dimafe6\BankID\Service\Controller' not found

I'm using this project in a Laravel framework version is 7,

Here what I did so far,

1) Added the package via using composer command 2) Created the Controller file to access the sign-in method.

When I try to test that controller file I'm getting that error.

Source file

<?php

namespace App\Http\Controllers;
namespace Dimafe6\BankID\Service;

use Illuminate\Http\Request;

class BankID extends Controller
{
    public function signin(){

        // Create BankIDService
        $bankIDService = new BankIDService(
            'https://appapi2.test.bankid.com/rp/v5/',
            $_SERVER["REMOTE_ADDR"],
            [
                'verify' => false,
                'cert'   => 'PATH_TO_TEST_CERT.pem',
            ]
        );

        // Signing. Step 1 - Get orderRef
        /** @var OrderResponse $response */
        $response = $bankIDService->getSignResponse('my test code', 'User visible data');

        // Signing. Step 2 - Collect orderRef. 
        // Repeat until $collectResponse->status !== CollectResponse::STATUS_COMPLETED
        $collectResponse = $bankIDService->collectResponse($response->orderRef);
        if($collectResponse->status === CollectResponse::STATUS_COMPLETED) {
            return true; //Signed successfully
        }
    }

    public function test(){
        return "hello";
    }
}

There is a folder in vendor folder which name dimafe6

m33ts4k0z commented 2 years ago

Use this:

use Dimafe6\BankID\Service\BankIDService;

and remove:

namespace Dimafe6\BankID\Service;