mardi 17 janvier 2017

Laravel GoCardless

I'm integrating Laravel with GoCardless to allow my users to take card payments however I'm struggling installing the GoCardless php wrapper.

I've followed the following doc: http://ift.tt/2iDGjeM

It says to use the following, am I right in saying this will go in my controller? surely with Laravel I wouldnt need to require the vendor/autoload?

<?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 http://ift.tt/2iKIm3R. You'll also
  // need to create a live app and update your client ID and secret.
  'http://ift.tt/2iDGreb',
  'http://ift.tt/2iKwBL0',
  ['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);

Apologies, if someone can point me in the right direction I would appreciate.

My controller currently looks like.

<?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(
          'http://ift.tt/2iDGreb',
          'REDIRECT_URL',
          ['scope' => 'read_write', 'initial_view' => 'login']
        );

        header("Location: " . $authorizeUrl);
    }
}

but I get the error:

Class 'App\Http\Controllers\OAuth2\Client' not found

Which makes sense because I haven't defined it in my controller but Im wondering how I would do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iDIvTu
via IFTTT

Aucun commentaire:

Enregistrer un commentaire