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 'PayPalCheckoutSdkCoreLiveEnvironment' 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): PeceeSimpleRouterRouteRoute->renderRoute(Object(PeceeHttpRequest)) #5 /api/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php(52): PeceeSimpleRouterRouter->routeRequest() #6 /api/sources/autoload.php(23): PeceeSimpleRouterSimpleRouter::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 PayPalCheckoutSdkCorePayPalHttpClient; use PayPalCheckoutSdkCoreSandboxEnvironment; use PayPalCheckoutSdkCoreLiveEnvironment; 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?
Advertisement
Answer
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/