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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…