In order to communicate with PayPal platform we need to set up a client first :
Create a client with sandbox environment
// import namespaceusePayPal\Http\Environment\SandboxEnvironment;usePayPal\Http\PayPalClient;// client id and client secret retrieved from PayPal$clientId ="<<PAYPAL-CLIENT-ID>>";$clientSecret ="<<PAYPAL-CLIENT-SECRET>>";// create a new sandbox environment$environment =newSandboxEnvironment($clientId, $clientSecret);// create a new client$client =newPayPalClient($environment);
Create a client with production environment
// import namespaceusePayPal\Http\Environment\ProductionEnvironment;usePayPal\Http\PayPalClient;// client id and client secret retrieved from PayPal$clientId ="<<PAYPAL-CLIENT-ID>>";$clientSecret ="<<PAYPAL-CLIENT-SECRET>>";// create a new sandbox environment$environment =newProductionEnvironment($clientId, $clientSecret);// create a new client$client =newPayPalClient($environment);