php - PayPal Checkout : LiveEnvironment class not found
问题描述
I am making a website with PayPal integration and I'm looking at the tutorial ... In sandbox everything works fine, but in Live it's not working...
The point is, the payment is well executed, but then I try to retrieve the order informations and I get :
<br />
<b>Fatal error</b>: Uncaught Error: Class 'PayPalCheckoutSdk\Core\LiveEnvironment' not found in /api/sources/Classes/PaypalClient.php:25
Stack trace:
#0 /api/sources/Classes/PaypalClient.php(16): PayPalClient::environment()
#1 /api/sources/Controllers/PaymentController.php(116): PayPalClient::client()
#2 [internal function]: PaymentController->update()
#3 /api/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Route/Route.php(119): call_user_func_array(Array, Array)
#4 /api/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php(286): Pecee\SimpleRouter\Route\Route->renderRoute(Object(Pecee\Http\Request))
#5 /api/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php(52): Pecee\SimpleRouter\Router->routeRequest()
#6 /api/sources/autoload.php(23): Pecee\SimpleRouter\SimpleRouter::start()
#7 /api/autoloader.php(7): require_once('/home/soinsdesz...')
#8 /api/public/index.php in <b>/api/sources/Classes/PaypalClient.php</b> on line <b>25</b><br />
This is my PaypalClient.php class :
<?php
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
use PayPalCheckoutSdk\Core\LiveEnvironment;
class PayPalClient
{
/**
* Returns PayPal HTTP client instance with environment that has access
* credentials context. Use this instance to invoke PayPal APIs, provided the
* credentials have access.
*/
public static function client()
{
return new PayPalHttpClient(self::environment());
}
/**
* Set up and return PayPal PHP SDK environment with PayPal access credentials.
* This sample uses SandboxEnvironment. In production, use LiveEnvironment.
*/
public static function environment()
{
return (ENV === "prod") ? new LiveEnvironment(PAYPAL_CLIENT_ID, PAYPAL_PRIVATE_KEY) : new SandboxEnvironment(PAYPAL_CLIENT_ID, PAYPAL_PRIVATE_KEY);
}
}
Can anyone help me please?
解决方案
Ok ... I found the solution ... So ...
In the tutorial it's said : "use LiveEnvironment instead" ... It's WRONG (thanks PayPal!!! Really) the correct class name is ProductionEnvironment !
Can PayPal modify his tutorial please : https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/
推荐阅读
- python - 不同准则的两次连续排序
- variables - Golang中不同的变量类型声明
- php - PHP preg_replace 适用于所有类型的年份格式(YYYY、YYYY-YYYY、YYYY - YYYY)
- api - 亚马逊商城网络服务创建入库货件 NOT_ELIGIBLE_FC_FOR_ITEM,有什么问题?
- javascript - 以后端期望的特定格式重构 JS 数组
- c# - UWP MediaPlayerElement 流超时
- grails - 以编程方式编辑 resources.groovy 文件
- jquery - 选择该选项时仅更改一个选项的颜色
- php - 函数 Hook add_post_meta ACF Post 对象
- c++ - vsperfcmd.exe 计算代码覆盖率不准确