Paypal Checkout SDK
  • Introduction
  • Requirements
  • Installation
  • Upgrading
  • Questions and issues
  • Changelog
  • Basic Usage
    • Create an Order
    • Show an Order
    • Capture an Order
  • Api
    • Amount
    • Amount Breakdown
    • Application Context
    • Item
    • Order
    • Payee
    • Purchase Unit
Powered by GitBook
On this page
  • Setup Credentials
  • Setup a Paypal Client
  • Create a client with sandbox environment
  • Create a client with production environment

Was this helpful?

Export as PDF

Installation

PreviousRequirementsNextUpgrading

Last updated 3 years ago

Was this helpful?

The supported way of installing paypal-checkout-sdk package is via Composer.

composer require phpjuice/paypal-checkout-sdk

Setup Credentials

Get client ID and client secret by going to and generating a REST API app. Get Client ID and Secret from there.

Setup a Paypal Client

In order to communicate with PayPal platform we need to set up a client first :

Create a client with sandbox environment

// import namespace
use PayPal\Http\Environment\SandboxEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

// create a new sandbox environment
$environment = new SandboxEnvironment($clientId, $clientSecret);

// create a new client
$client = new PayPalClient($environment);

Create a client with production environment

// import namespace
use PayPal\Http\Environment\ProductionEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

// create a new sandbox environment
$environment = new ProductionEnvironment($clientId, $clientSecret);

// create a new client
$client = new PayPalClient($environment);
https://developer.paypal.com/developer/applications