首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel GoCardless

Laravel GoCardless
EN

Stack Overflow用户
提问于 2017-01-17 17:34:58
回答 1查看 636关注 0票数 2

我正在将Laravel与GoCardless集成,以允许我的用户接受信用卡支付,但是我在安装GoCardless php包装程序时遇到了困难。

我跟踪了以下文档:https://developer.gocardless.com/getting-started/partners/building-an-authorisation-link/

它说,使用下面的,我说的对吗,这将在我的控制器?当然,对于拉勒维尔,我不需要要求供应商/自动售货机?

代码语言:javascript
复制
<?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);

抱歉,如果有人能给我指明正确的方向,我会很感激的。

我的控制器现在看起来。

代码语言:javascript
复制
<?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’

这是有意义的,因为我还没有在我的控制器中定义它,但我想知道我将如何做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2017-01-17 19:40:54

在你的控制器里试试这个:

代码语言:javascript
复制
use Oauth2;

或者,$client = new \OAuth2\Client(....确实注意到Oauth2之前的\

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41703514

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档