致命错误:在 sdk Paypal 中找不到“PaypalApiPayer"类
我用 composer 安装了 PayPal SDK,但我的 php 文件 CHECKOUT.php 错误是:
I installed PayPal SDK with composer but my php file CHECKOUT.php the error is:
致命错误:未找到类PaypalApiPayer"C:xampphtdocspagoscheckout.php 第 23 行
Fatal error: Class 'PaypalApiPayer' not found in C:xampphtdocspagoscheckout.php on line 23
checkout.php:
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'
]);
推荐答案
代替:使用PaypalApiPayer;
使用PaypalApiItem;
改为:使用PayPalApiPayer;
使用PayPalApiItem;
只需将PayPal"一词的第二个P"大写.希望它有效:)
Just capitalize the second "P" on the word "PayPal". Hope it works :)
相关文章