致命错误:未在sdk Paypal中找到“ Paypal \ Api \ Payer”类

Ale*_*e89 3 php paypal paypal-sandbox paypal-rest-sdk

我用作曲家安装了PayPal SDK,但我的php文件CHECKOUT.php出现错误:

致命错误:在第23行的C:\ xampp \ htdocs \ pagos \ checkout.php中找不到类“ Paypal \ Api \ Payer”

checkout.php:

<?php
require ("start.php");

use Paypal\Api\Payer;
use Paypal\Api\Item;

$payer = new Payer();
$payer->setPaymentMethod("paypal");

$item = new Item();
$item->setName($descripcion)
    ->setCurrency('MXN')
    ->setQuantity(1)
    ->setPrice($precio);
$itemList = new ItemList();
$itemList->setItems([$item]);
Run Code Online (Sandbox Code Playgroud)

start.php

<?php
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
// Used for composer based installation
require __DIR__  . '/vendor/autoload.php';
// Use below for direct download installation
// require __DIR__  . '/PayPal-PHP-SDK/autoload.php';  

$apiContext = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
        'ashdjkhaskdjhalksdfjhaglskjdfhlasdfasdfsdfgh',     // ClientID
        'ejkhsdkjhakjdhakjshdkjashdkjashdkjaskjdhaskjh'      // ClientSecret
    )
);

$apiContext->setConfig([
 'mode'=>'sandbox',
 'http.ConnectionTimeOut'=>30,
 'log.LogEnabled'=>false,
 'log.FileName'=>'',
 'log.LogLevel'=>'FINE',
 'validation.level'=>'log'
]);
Run Code Online (Sandbox Code Playgroud)

小智 5

代替:
use Paypal\Api\Payer;
use Paypal\Api\Item;

更改为:
use PayPal\Api\Payer;
use PayPal\Api\Item;

只需在单词“ PayPal”上将第二个“ P”大写。希望它能工作:)