Configure Your Environment
Important: These
/v1/payments
and general-purpose REST SDKs are deprecated. See our current SDK offerings, which include the/v2/checkout
and Payouts use cases. For other APIs, use direct integration.
After you install the SDK, you must make the SDK available to your app and configure your environment. Configuration details include the mode, which is sandbox
for testing or live
for production, and your client ID and secret for your app.
Note: To get a client ID and secret, use the Developer Dashboard to get credentials.
In the directory where you installed the SDK, create a file in your preferred language. In the file, include the following code to make the SDK available, and configure your environment with your application credentials.
var paypal = require('paypal-rest-sdk'); paypal.configure({ mode: 'sandbox', // Sandbox or live client_id: 'YOUR APPLICATION CLIENT ID', client_secret: 'YOUR APPLICATION CLIENT SECRET'});
// Autoload SDK package for composer based installations require 'vendor/autoload.php'; $apiContext = new \PayPal\Rest\ApiContext( new \PayPal\Auth\OAuthTokenCredential( 'YOUR APPLICATION CLIENT ID', 'YOUR APPLICATION CLIENT SECRET' ) );
import paypalrestsdk paypalrestsdk.configure({ 'mode': 'sandbox', #sandbox or live 'client_id': 'YOUR APPLICATION CLIENT ID', 'client_secret': 'YOUR APPLICATION CLIENT SECRET' })
require 'paypal-sdk-rest' include PayPal::SDK::REST include PayPal::SDK::Core::Logging PayPal::SDK.configure( :mode => 'sandbox', #sandbox or live :client_id => 'YOUR APPLICATION CLIENT ID', :client_secret => 'YOUR APPLICATION CLIENT SECRET', :ssl_options => { } )
import com.paypal.base.rest.APIContext; import com.paypal.base.rest.PayPalRESTException; // Replace with your application client ID and secret String clientId = "YOUR APPLICATION CLIENT ID"; String clientSecret = "YOUR APPLICATION CLIENT SECRET"; APIContext context = new APIContext(clientId, clientSecret, "sandbox");
// Add to web.config or app.config <configuration> <configSections> <section name="paypal" type="PayPal.SDKConfigHandler, PayPal" /> </configSections> <!-- PayPal SDK settings --> <paypal> <settings> <add name="mode" value="sandbox"/> <add name="clientId" value="YOUR APPLICATION CLIENT ID"/> <add name="clientSecret" value="YOUR APPLICATION CLIENT SECRET"/> </settings> </paypal> </configuration> // Add to code using PayPal.Api; // Authenticate with PayPal var config = ConfigManager.Instance.GetProperties(); var accessToken = new OAuthTokenCredential(config).GetAccessToken(); var apiContext = new APIContext(accessToken);
Note: PayPal Checkout v2 is available for the Orders and Payments REST APIs. For integration instructions using v2, see the v2 server-side SDK documentation.
Next
- Process payments
- Create future or delayed payments
- Manage your existing payments
- Create notifications for your payments
Additional information
SDK Repositories: Java v2 Checkout | Java | .NET v2 Checkout | .NET | Node v2 Checkout | Node | PHP v2 Checkout| PHP | Python v2 Checkout | Python | Ruby v2 Checkout| Ruby