Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

php - Fatal error: Class 'PaypalApiPayer' not found en sdk Paypal

I installed PayPal SDK with composer but my php file CHECKOUT.php the error is:

Fatal error: Class 'PaypalApiPayer' not found in C:xampphtdocspagoscheckout.php on line 23

checkout.php:

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

use PaypalApiPayer;
use PaypalApiItem;

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

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

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 PayPalRestApiContext(
    new PayPalAuthOAuthTokenCredential(
        'ashdjkhaskdjhalksdfjhaglskjdfhlasdfasdfsdfgh',     // ClientID
        'ejkhsdkjhakjdhakjshdkjashdkjashdkjaskjdhaskjh'      // ClientSecret
    )
);

$apiContext->setConfig([
 'mode'=>'sandbox',
 'http.ConnectionTimeOut'=>30,
 'log.LogEnabled'=>false,
 'log.FileName'=>'',
 'log.LogLevel'=>'FINE',
 'validation.level'=>'log'
]);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of:
use PaypalApiPayer;
use PaypalApiItem;

Change it to:
use PayPalApiPayer;
use PayPalApiItem;

Just capitalize the second "P" on the word "PayPal". Hope it works :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...