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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With