我试图在laravel 5.5中使用以下依赖项

https://github.com/anouarabdsslm/laravel-paypalpayment

laravel 5.5 Class App \ Http \ Controllers \ PaypalPayment中的错误不存在 . 我没有设法打电话给PaypalPayment类 . “使用Paypalpayment”不起作用 .

Capture del error

Error:

C:\xampp\htdocs\laravel-paypal - copia\vendor\laravel\framework\src\Illuminate\Container\Container.php
}

/**
 * Instantiate a concrete instance of the given type.
 *
 * @param  string  $concrete
 * @return mixed
 *
 * @throws \Illuminate\Contracts\Container\BindingResolutionException
 */
public function build($concrete)
{
    // If the concrete type is actually a Closure, we will just execute it and
    // hand back the results of the functions, which allows functions to be
    // used as resolvers for more fine-tuned resolution of these objects.
    if ($concrete instanceof Closure) {
        return $concrete($this, $this->getLastParameterOverride());
    }

    $reflector = new ReflectionClass($concrete);

    // If the type is not instantiable, the developer is attempting to resolve
    // an abstract type such as an Interface of Abstract Class and there is
    // no binding registered for the abstractions so we need to bail out.
    if (! $reflector->isInstantiable()) {
        return $this->notInstantiable($concrete);
    }

    $this->buildStack[] = $concrete;

    $constructor = $reflector->getConstructor();

    // If there are no constructors, that means there are no dependencies then
    // we can just resolve the instances of the objects right away, without
    // resolving any other types or dependencies out of these containers.
    if (is_null($constructor)) {
        array_pop($this->buildStack);

        return new $concrete;
    }

参数“Class App \ Http \ Controllers \ PaypalPayment不存在”

文件配置/应用程序

<?php

返回[

/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/

'name' => env('APP_NAME', 'Laravel'),

/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/

'env' => env('APP_ENV', 'production'),

/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/

'debug' => env('APP_DEBUG', false),

/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/

'url' => env('APP_URL', 'http://localhost'),

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/

'timezone' => 'UTC',

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/

'locale' => 'en',

/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/

'fallback_locale' => 'en',

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/

'key' => env('APP_KEY'),

'cipher' => 'AES-256-CBC',

/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/

'log' => env('APP_LOG', 'single'),

'log_level' => env('APP_LOG_LEVEL', 'debug'),

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Notifications\NotificationServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,

    /*
     * Package Service Providers...
     */

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,
    Collective\Html\HtmlServiceProvider::class,
    Anouar\Paypalpayment\PaypalpaymentServiceProvider::class,

],

/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => [

    'App'          => Illuminate\Support\Facades\App::class,
    'Artisan'      => Illuminate\Support\Facades\Artisan::class,
    'Auth'         => Illuminate\Support\Facades\Auth::class,
    'Blade'        => Illuminate\Support\Facades\Blade::class,
    'Broadcast'    => Illuminate\Support\Facades\Broadcast::class,
    'Bus'          => Illuminate\Support\Facades\Bus::class,
    'Cache'        => Illuminate\Support\Facades\Cache::class,
    'Config'       => Illuminate\Support\Facades\Config::class,
    'Cookie'       => Illuminate\Support\Facades\Cookie::class,
    'Crypt'        => Illuminate\Support\Facades\Crypt::class,
    'DB'           => Illuminate\Support\Facades\DB::class,
    'Eloquent'     => Illuminate\Database\Eloquent\Model::class,
    'Event'        => Illuminate\Support\Facades\Event::class,
    'File'         => Illuminate\Support\Facades\File::class,
    'Gate'         => Illuminate\Support\Facades\Gate::class,
    'Hash'         => Illuminate\Support\Facades\Hash::class,
    'Lang'         => Illuminate\Support\Facades\Lang::class,
    'Log'          => Illuminate\Support\Facades\Log::class,
    'Mail'         => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password'     => Illuminate\Support\Facades\Password::class,
    'Queue'        => Illuminate\Support\Facades\Queue::class,
    'Redirect'     => Illuminate\Support\Facades\Redirect::class,
    'Redis'        => Illuminate\Support\Facades\Redis::class,
    'Request'      => Illuminate\Support\Facades\Request::class,
    'Response'     => Illuminate\Support\Facades\Response::class,
    'Route'        => Illuminate\Support\Facades\Route::class,
    'Schema'       => Illuminate\Support\Facades\Schema::class,
    'Session'      => Illuminate\Support\Facades\Session::class,
    'Storage'      => Illuminate\Support\Facades\Storage::class,
    'URL'          => Illuminate\Support\Facades\URL::class,
    'Validator'    => Illuminate\Support\Facades\Validator::class,
    'View'         => Illuminate\Support\Facades\View::class,
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,

'Paypalpayment'=> Anouar \ Paypalpayment \ Facades \ PaypalPayment :: class,

],

] .

File Class Paypalpayment in Vendor

<?php
namespace Anouar\Paypalpayment;

use Illuminate\Support\Facades\URL;
use PayPal\Api\Address;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Authorization;
use PayPal\Api\Capture;
use PayPal\Api\CreditCard;
use PayPal\Api\CreditCardToken;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Links;
use PayPal\Api\Payee;
use PayPal\Api\Payer;
use PayPal\Api\PayerInfo;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\PaymentHistory;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Refund;
use PayPal\Api\RelatedResources;
use PayPal\Api\Sale;
use PayPal\Api\ShippingAddress;
use PayPal\Api\Transaction;
use PayPal\Api\Transactions;
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;

class PaypalPayment
{
    protected $config;

    public function __construct(array $config)
    {
        $this->config = $config;
    }

    /**
     * @return \PayPal\Api\Address
     */
    public function address()
    {
        return new Address;
    }

    /**
     * @return \PayPal\Api\Amount
     */
    public function amount()
    {
        return new Amount;
    }

    /**
     * @return \PayPal\Api\Details
     */
    public function details()
    {
        return new Details;
    }

    /**
     * @return \PayPal\Api\Authorization
     */
    public function authorization()
    {
        return new Authorization;
    }

    /**
     * @return \PayPal\Api\Capture
     */
    public function capture()
    {
        return new Capture;
    }

    /**
     * @return \PayPal\Api\CreditCard
     */
    public function creditCard()
    {
        return new CreditCard;
    }

    /**
     * @return \PayPal\Api\CreditCardToken
     */
    public function creditCardToken()
    {
        return new CreditCardToken;
    }

    /**
     * @return \PayPal\Api\FundingInstrument
     */
    public function fundingInstrument()
    {
        return new FundingInstrument;
    }

    /**
     * @return \PayPal\Api\Item
     */
    public function item()
    {
        return new Item;
    }

    /**
     * @return \PayPal\Api\ItemList
     */
    public function itemList()
    {
        return new ItemList;
    }

    /**
     * @return \PayPal\Api\Links
     */
    public function links()
    {
        return new Links;
    }

    /**
     * @return \PayPal\Api\Payee
     */
    public function payee()
    {
        return new Payee;
    }

    /**
     * @return \PayPal\Api\Payer
     */
    public function payer()
    {
        return new Payer;
    }

    /**
     * @return \PayPal\Api\PayerInfo
     */
    public function payerInfo()
    {
        return new PayerInfo;
    }

    /**
     * @return \PayPal\Api\Payment
     */
    public function payment()
    {
        return new Payment;
    }

    /**
     * @return \PayPal\Api\PaymentExecution
     */
    public function paymentExecution()
    {
        return new PaymentExecution;
    }

    /**
     * @return \PayPal\Api\PaymentHistory
     */
    public function paymentHistory()
    {
        return new PaymentHistory;
    }

    /**
     * @return \PayPal\Api\RedirectUrls
     */
    public function redirectUrls()
    {
        return new RedirectUrls;
    }

    /**
     * @return \PayPal\Api\Refund
     */
    public function refund()
    {
        return new Refund;
    }

    /**
     * @return \PayPal\Api\RelatedResources
     */
    public function relatedResources()
    {
        return new RelatedResources;
    }

    /**
     * @return \PayPal\Api\Sale
     */
    public function sale()
    {
        return new Sale;
    }

    /**
     * @return \PayPal\Api\ShippingAddress
     */
    public function shippingAddress()
    {
        return new ShippingAddress;
    }

    /**
     * @return \PayPal\Api\Transactions
     */
    public function transactions()
    {
        return new Transactions;
    }

    /**
     * @return \PayPal\Api\Transaction
     */
    public function transaction()
    {
        return new Transaction;
    }


    /**
     * @param null $clientId
     * @param null $clientSecret
     * @param null $requestId
     * @return \PayPal\Rest\ApiContext
     */
    public function apiContext($clientId = null, $clientSecret = null, $requestId = null)
    {
        if (!is_null($clientId)) {
            $this->config['account']['client_id'] = $clientId;
        }

        if (!is_null($clientSecret)) {
            $this->config['account']['client_secret'] = $clientSecret;
        }

        $apiContext = new ApiContext($this->oAuthTokenCredential(), $requestId);

        $apiContext->setConfig([
            'mode' => $this->config['mode'],
            'http.ConnectionTimeOut' => $this->config['http']['connection_time_out'],
            'log.LogEnabled' => $this->config['log']['log_enabled'],
            'log.FileName' => $this->config['log']['file_name'],
            'log.LogLevel' => $this->config['log']['log_level']
        ]);

        return $apiContext;
    }

    /**
     * @param null $clientId
     * @param null $clientSecret
     * @return PayPal/Auth/OAuthTokenCredential
     */
    public function oAuthTokenCredential()
    {
        return new OAuthTokenCredential($this->config['account']['client_id'], $this->config['account']['client_secret']);
    }

    /**
     * Get the base URL
     * @return mixed
     */
    public function getBaseUrl()
    {
        return URL::to('/');
    }


    public static function getById($paymentId, $apiContext = null)
    {
        if (isset($apiContext)) {
            return Payment::get($paymentId, $apiContext);
        }
        return Payment::get($paymentId);
    }

    /**
     * grape all payment details
     * @param $param
     * @param null $apiContext
     * @return \PayPal\Api\Payment
     */
    public static function getAll($param, $apiContext = null)
    {
        if (isset($apiContext)) {
            return Payment::all($param, $apiContext);
        }
        return Payment::all($param);
    }
}

Config/App

<?php


    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,

        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        Collective\Html\HtmlServiceProvider::class,
        Anouar\Paypalpayment\PaypalpaymentServiceProvider::class,

    ],

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [

        'App'          => Illuminate\Support\Facades\App::class,
        'Artisan'      => Illuminate\Support\Facades\Artisan::class,
        'Auth'         => Illuminate\Support\Facades\Auth::class,
        'Blade'        => Illuminate\Support\Facades\Blade::class,
        'Broadcast'    => Illuminate\Support\Facades\Broadcast::class,
        'Bus'          => Illuminate\Support\Facades\Bus::class,
        'Cache'        => Illuminate\Support\Facades\Cache::class,
        'Config'       => Illuminate\Support\Facades\Config::class,
        'Cookie'       => Illuminate\Support\Facades\Cookie::class,
        'Crypt'        => Illuminate\Support\Facades\Crypt::class,
        'DB'           => Illuminate\Support\Facades\DB::class,
        'Eloquent'     => Illuminate\Database\Eloquent\Model::class,
        'Event'        => Illuminate\Support\Facades\Event::class,
        'File'         => Illuminate\Support\Facades\File::class,
        'Gate'         => Illuminate\Support\Facades\Gate::class,
        'Hash'         => Illuminate\Support\Facades\Hash::class,
        'Lang'         => Illuminate\Support\Facades\Lang::class,
        'Log'          => Illuminate\Support\Facades\Log::class,
        'Mail'         => Illuminate\Support\Facades\Mail::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
        'Password'     => Illuminate\Support\Facades\Password::class,
        'Queue'        => Illuminate\Support\Facades\Queue::class,
        'Redirect'     => Illuminate\Support\Facades\Redirect::class,
        'Redis'        => Illuminate\Support\Facades\Redis::class,
        'Request'      => Illuminate\Support\Facades\Request::class,
        'Response'     => Illuminate\Support\Facades\Response::class,
        'Route'        => Illuminate\Support\Facades\Route::class,
        'Schema'       => Illuminate\Support\Facades\Schema::class,
        'Session'      => Illuminate\Support\Facades\Session::class,
        'Storage'      => Illuminate\Support\Facades\Storage::class,
        'URL'          => Illuminate\Support\Facades\URL::class,
        'Validator'    => Illuminate\Support\Facades\Validator::class,
        'View'         => Illuminate\Support\Facades\View::class,
        'Form' => Collective\Html\FormFacade::class,
        'Html' => Collective\Html\HtmlFacade::class,
'Paypalpayment'   => Anouar\Paypalpayment\Facades\PaypalPayment::class,

    ],

];

Controller edited

class PaypalPaymentController extends Controller

{/ * 使用信用卡处理付款 /公共职能paywithCreditCard(){

// ### Address
    // Base Address object used as shipping or billing
    // address in a payment. [Optional]
    $shippingAddress = PaypalPayment::shippingAddress();
    $shippingAddress->setLine1("3909 Witmer Road")
        ->setLine2("Niagara Falls")
        ->setCity("Niagara Falls")
        ->setState("NY")
        ->setPostalCode("14305")
        ->setCountryCode("US")
        ->setPhone("716-298-1822")
        ->setRecipientName("Jhone");

    // ### CreditCard
    $card = PaypalPayment::creditCard();
    $card->setType("visa")
        ->setNumber("4758411877817150")
        ->setExpireMonth("05")
        ->setExpireYear("2019")
        ->setCvv2("456")
        ->setFirstName("Joe")
        ->setLastName("Shopper");

    // ### FundingInstrument
    // A resource representing a Payer's funding instrument.
    // Use a Payer ID (A unique identifier of the payer generated
    // and provided by the facilitator. This is required when
    // creating or using a tokenized funding instrument)
    // and the `CreditCardDetails`
    $fi = PaypalPayment::fundingInstrument();
    $fi->setCreditCard($card);

    // ### Payer
    // A resource representing a Payer that funds a payment
    // Use the List of `FundingInstrument` and the Payment Method
    // as 'credit_card'
    $payer = PaypalPayment::payer();
    $payer->setPaymentMethod("credit_card")
        ->setFundingInstruments([$fi]);

    $item1 = PaypalPayment::item();
    $item1->setName('Ground Coffee 40 oz')
            ->setDescription('Ground Coffee 40 oz')
            ->setCurrency('USD')
            ->setQuantity(1)
            ->setTax(0.3)
            ->setPrice(7.50);

    $item2 = PaypalPayment::item();
    $item2->setName('Granola bars')
            ->setDescription('Granola Bars with Peanuts')
            ->setCurrency('USD')
            ->setQuantity(5)
            ->setTax(0.2)
            ->setPrice(2);


    $itemList = PaypalPayment::itemList();
    $itemList->setItems([$item1,$item2])
        ->setShippingAddress($shippingAddress);


    $details = PaypalPayment::details();
    $details->setShipping("1.2")
            ->setTax("1.3")
            //total of items prices
            ->setSubtotal("17.5");

    //Payment Amount
    $amount = PaypalPayment::amount();
    $amount->setCurrency("USD")
            // the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
            ->setTotal("20")
            ->setDetails($details);

    // ### Transaction
    // A transaction defines the contract of a
    // payment - what is the payment for and who
    // is fulfilling it. Transaction is created with
    // a `Payee` and `Amount` types

    $transaction = PaypalPayment::transaction();
    $transaction->setAmount($amount)
        ->setItemList($itemList)
        ->setDescription("Payment description")
        ->setInvoiceNumber(uniqid());

    // ### Payment
    // A Payment Resource; create one using
    // the above types and intent as 'sale'

    $payment = PaypalPayment::payment();

    $payment->setIntent("sale")
        ->setPayer($payer)
        ->setTransactions([$transaction]);

    try {
        // ### Create Payment
        // Create a payment by posting to the APIService
        // using a valid ApiContext
        // The return object contains the status;
        $payment->create(PaypalPayment::apiContext());
    } catch (\PPConnectionException $ex) {
        return response()->json(["error" => $ex->getMessage()], 400);
    }

    return response()->json([$payment->toArray()], 200);
}

}