我正在将Laravel与GoCardless集成,以允许我的用户接受信用卡支付,但是我在安装GoCardless php包装程序时遇到了困难。
我跟踪了以下文档:https://developer.gocardless.com/getting-started/partners/building-an-authorisation-link/
它说,使用下面的,我说的对吗,这将在我的控制器?当然,对于拉勒维尔,我不需要要求供应商/自动售货机?
<?php
require 'vendor/autoload.php';
// You should store your client ID and secret in environment variables rather than
// committing them with your code
$client = new OAuth2\Client(getenv('GOCARDLESS_CLIENT_ID'), getenv('GOCARDLESS_CLIENT_SECRET'));
$authorizeUrl = $client->getAuthenticationUrl(
// Once you go live, this should be set to https://connect.gocardless.com. You'll also
// need to create a live app and update your client ID and secret.
'https://connect-sandbox.gocardless.com/oauth/authorize',
'https://acme.enterprises/redirect',
['scope' => 'read_write', 'initial_view' => 'login']
);
// You'll now want to direct your user to the URL - you could redirect them or display it
// as a link on the page
header("Location: " . $authorizeUrl);抱歉,如果有人能给我指明正确的方向,我会很感激的。
我的控制器现在看起来。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class goCardlessController extends Controller
{
public function index()
{
$client = new OAuth2\Client(env('GOCARDLESS_CLIENT_ID'), env('GOCARDLESS_CLIENT_SECRET'));
$authorizeUrl = $client->getAuthenticationUrl(
'https://connect-sandbox.gocardless.com/oauth/authorize',
'REDIRECT_URL',
['scope' => 'read_write', 'initial_view' => 'login']
);
header("Location: " . $authorizeUrl);
}
}但我知道错误是:
未找到类‘App\Http\Controller\OAuth2\Client’
这是有意义的,因为我还没有在我的控制器中定义它,但我想知道我将如何做到这一点?
发布于 2017-01-17 19:40:54
在你的控制器里试试这个:
use Oauth2;或者,$client = new \OAuth2\Client(....确实注意到Oauth2之前的\
https://stackoverflow.com/questions/41703514
复制相似问题