PayPal Checkout:未找到LiveEnvironment类

问题描述 投票:0回答:1

[我正在建立一个具有PayPal集成的网站,我正在看教程...在沙盒中,一切正常,但是在Live中,它无法正常工作...

关键是,付款执行得很好,但是随后我尝试检索订单信息,我得到了:

<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-&gt;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-&gt;renderRoute(Object(Pecee\Http\Request))
#5 /api/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php(52): Pecee\SimpleRouter\Router-&gt;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 />

这是我的PaypalClient.php类:

<?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);
    }
}

有人可以帮我吗?

php paypal
1个回答
0
投票

确定,我找到了解决方法,所以...

在本教程中说:“改为使用LiveEnvironment” ...它是WRONG(感谢PayPal !!)正确的类名是ProductionEnvironment

PayPal可以修改他的教程吗:https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/

© www.soinside.com 2019 - 2024. All rights reserved.